helpful when you see something like this: zsh: argument list too long: cp
Use shell expansion to create a back-up copy (file.txt.bak) of a file (file.txt) and keep the original last modified date and time.
If you have a series of existing files in a directory that you would like to copy to a new series, and then make a series of changes to those new files, this will speed up the process of copying the files. You can later iterate through a loop and use sed -i -e 's/old_string/new-string' new_string_files.* to replace all the values you need to in the newly copied files. Show Sample Output
Given a cbr file which is rar compressed, get a cbz file which is zip compressed.
Music Library Convert Usage lc Old_Directory New_DIrectory Old_Format New_Format lc ~/Music ~/Music_ogg mp3 ogg This will convert all audio files in the old directory to the new directory from the old format to the new format. It will leave the original library alone. The converted library will retain folder structure.
I used this to resolve runtime dependencies of an application to create self-contained tar-balls (e.g. PHP for Docker or Rkt) Requirements: - realpath - ldd - find - grep - sort - uniq - xargs
file_to_backup{,-$(date +%F)} expands to the following two items: file_to_backup file_to_backup-$(date +%F) Show Sample Output
Only the first appearance of a repeated command in the history will be kept. Otherwise, if you prefer to keep last occurrence of a repeated command then maybe you can achieve that by including reverse input/output i.e with 'tac' command in expression above.
To see statistics of removed repeated commands:
diff --suppress-common-lines -y ~/.bash_history.bak ~/.bash_history|uniq -c|sort -n|tr -s " "|sed '/^ 1/d'|grep '<'
Kernel developers might need to know what indices to map to the IOAPIC if building a new kernel from scratch. This command gives users a guide to go off of.
quick in directory backup of all files in this directory. Adds the .bak extension to all copies.
If like me you do a lot of front-end coding and you have a lot of clients that asks you some little modifications, then you send the modifications back to them in a zip file while ignoring the .git folder and .gitignore file, then copy this zip into your dropbox and send it back to them. They find out a new bug so, rince and repeat? You get the picture. It can be quite tedious.
Change the value of p to match the path where you wish to create the profile. To run it again in the future, use the parameter --user-data-dir (which gets echoed to you when run): chromium-browser --user-data-dir=/path/to/your/ Quick Functions: # create a new chromium profile new-chromium-profile() { p=~/.config/chromium/$1; cp -r ~/.config/chromium/Default $p && echo "chromium-browser --user-data-dir=$p" && chromium-browser --user-data-dir=$p; } # runs a chromium profile run-chromium-profile() { chromium-browser --user-data-dir=~/.config/chromium/$1; } Show Sample Output
This will tighten up security for your box. The default value for PermitRootLogin sadly is 'yes'.
Take a folder full of files and split it into smaller folders containing a maximum number of files. In this case, 100 files per directory. find creates the list of files xargs breaks up the list into groups of 100 for each group, create a directory and copy in the files Note: This command won't work if there is whitespace in the filenames (but then again, neither do the alternative commands :-)
preserve all except context and xattr. useful when moving a running system to a new partition.
You must spezify /where folder and / folder If you have another camera you must experiment with Exif data (after -g and after grep) and mask of your photo files IMG_????.JPG I have do it on Knoppix 6.7.0 You must have installed exiv2. Show Sample Output
As cp is often an alias to cp -i you can use \cp (or cp full path /bin/cp) to use the real cp command instead of its alias
for filename multilingual (ex.japanese, chinese, ...etc)
Select only the files with given name and copy them to /tmp/ folder.
"." is current dir, maxdepth is the level, -print0 | xargs -0 fix spaces in names, -i interactive , ./ is the current dir {} actual name , and {,.bak} is the atual name + bak
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: