'newfile' will have content of 'file' minus first 55 lines to delete first line only do: tail +2 file > newfile
for file in `ls -t \`find . -name "*.zip" -type f\``; do found=`unzip -c "$file" | grep --color=always "PATTERN"`; if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi done
Runs the identify command (from ImageMagick) on each jpg file in the current directory and returns image details according to the format parameter. The example here returns: Filename FileSize Compression Width Height More information about the available format options can be found here: http://www.imagemagick.org/script/escape.php I usually redirect the output to a text file using "> listofdetails.txt" at the end. Spreadsheet magic can then be applied. Show Sample Output
Let the shell handle the repetition in stead of find :)
You can implement a FOR loop to act on one or more files returned from the IN clause. We originally found this in order to GPG decrypt a file using wildcards (where you don't know exactly the entire file name, i.e.: Test_File_??????.txt, where ?????? = the current time in HHMMSS format). Since we won't know the time the file was generated, we need to use wildcards. And as a result of GPG not handling wildcards, this is the perfect solution. Thought I would share this revelation. :-) Show Sample Output
To ignore aspect ratio, run: for file in *; do convert $file -resize 800x600! resized-$file; done and all images will be exactly 800x600. Use your shell of choice.. This was done in BASH. Show Sample Output
Created to deal with an overzealous batch rename on our server that renamed all files to .jpg files.
For some reason split will not let you add extension to the files you split. Just add this to a .sh script and run with bash or sh and it will split your text file at 12000 lines for each file and then add a .sql extension to the file name.
Strips the audio track from a webm video. Use this in combination with clive or youtube-dl.
nice trick with the :>! this is a variant to do a bunch of files (e.g. *.log) in one go
In this example I am returning all the files in /usr/bin that weren't put there by pacman, so that they can be moved to /usr/local/bin where they (most likely) belong. Show Sample Output
helpful when you see something like this: zsh: argument list too long: cp
this command can be added to crontab so as to execute a nightly backup of directories and store only the 10 last backup files.
This will add a perl POD stub above each method in all modules found recursively in your current directory. The stub will look like: =head2 method_name =cut sub method_name { ...
This oneliner will allow you to strip the part of names in a bunch of files. I needed this to rename songs names. Show Sample Output
This command will take the output of curl and read it line by line, skipping a step in downloading the file then parsing it. You can then parse each line, or only print the lines that contain certain works using if statements, or whatever you can come up with. Or you can change IFS and use it to parse based on separators other than newline.
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: