empties a file... --- fir3net.com ---
only for non-regexp-split - else use preg_split instead.
grep multiline in Perl regexp syntax with pcregrep Show Sample Output
range context (-A -B) search, with exclusion of vcs directories Show Sample Output
{ ... } vs ( ... ) reduces the process count, I believe. Typically, I use this logic to redirect a series of commands to a pipe -- { command1 args1 ; command2 args2}|less -- or file -- { command1 args1 ; command2 args2}>foo -- or to spawn the series as a background process -- { ... } & .
You can find a command's history event number via the `history` command.
You can also put the history event number in your prompt: \! for bash, or %h for zsh.
Finally, I would like to point out that by "number", I mean POSITIVE INTEGER. Not, say, a letter, such as 'm'. Examples:
!1
or
!975
Show Sample Output
useful to count events in logs @see: http://www.commandlinefu.com/commands/view/10327/report-summary-of-string-occurrence-by-time-period-hour#comment Show Sample Output
List background jobs, grep their number - not process id - and then kill them Show Sample Output
ssh port forwading
OpenDocument documents from OpenOffice.org,LibreOffice
and other applications, are actually ZIP archives.
Useful informations in these archives are in XML format.
Here we like it or do not. Anyway, the XML files have the unfortunate tendency to
not be indented, and for good reason: they consist of only one line!
To solve the problem and to use a proper editor on the content,
I proceed as follows.
Required xmlindent
You can also use :
zip document.odt content.xml
And it works with vi instead of nano !
The -a option in -aEio tells grep to treat binary files as text files. Show Sample Output
Useful if localhost is a small machine running BusyBox, which uses a slightly unusual format to set the date. Remotehost can be pretty much any Linux machine, including one running BusyBox. Uses UTC for portability.
I just used this to lowercase many gigs of old data we had lying around from a bunch of legacy DOS and win95/98 drives. WARNING - The entire directory is removed as the second command to help save working space and save an additional step. BE CAREFUL. In the unzip portion the -LL switch forces all extracted files and dirs to lower case, and the -0 speeds things up significantly by using no compression when making the zip file (but uses more space). Worked perfect and quickly for me after trying many other not so successful commands.
Use: find . ! -readable -prune or more generally find ! -readable -prune -o -print to avoid "Permission denied" AND do NOT suppress (other) error messages AND get exit status 0 ("all files are processed successfully") Works with: find (GNU findutils) 4.4.2. Background: The -readable test matches readable files. The ! operator returns true, when test is false. And ! -readable matches not readable directories (&files). The -prune action does not descend into directory. ! -readable -prune can be translated to: if directory is not readable, do not descend into it. The -readable test takes into account access control lists and other permissions artefacts which the -perm test ignores. For find versions without -readable test, you can check permissions: find . ! -perm -g+r,u+r,o+r -prune Adapted from stackoverflow: http://stackoverflow.com/questions/762348/how-can-i-exclude-all-permission-denied-messages-from-find
greps using only ascii, skipping the overhead of matching UTF chars. Some stats: $ export LANG=C; time grep -c Quit /var/log/mysqld.log 7432 real 0m0.191s user 0m0.112s sys 0m0.079s $ export LANG=en_US.UTF-8; time grep -c Quit /var/log/mysqld.log 7432 real 0m13.462s user 0m9.485s sys 0m3.977s Try strace-ing grep with and without LANG=C
Detect video size automatically , usually the flv video from youtube , dailymotion are in the /tmp directory . Just launch a video player or an ls -lh on it to find the one you want to convert. Show Sample Output
A bit shorter and parallelized. Depending on the speed of your cpu and your disk this may run faster. Parallel is from https://savannah.nongnu.org/projects/parallel/
Same result with simpler regular expression.. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: