This requires a version of GNU find that supports the -exec {} + action, but it seems more straightforward than the versions already posted. Show Sample Output
NOTE that pax goes always recursively, for that reason -d option should be added when you don't want to go recursively into directories.
Like the above, but runs a single rm command
"-exec" ftw.
To use this comment you'll have to create a file entitled 'ignorelist' where you put the file name or pattern of the files you want to ignore. I used it for my maven project which generates the child project files in each folder so I can import them into eclipse. By adding these project files to the ignore list ensure they won't appear each time I run 'svn status'. Show Sample Output
Code to delete file with gremlins/special characters/unicode in file name. Use ls -i to find the INODE number corresponding to the file and then delete it using that find statement. detailed here: http://www.arsc.edu/arsc/support/howtos/nonprintingchars/ Show Sample Output
Copy files and dir in parallel. It is Faster.
Using the gnu-parallel.
Has 2 commands:
- First - Create dir structure in /BKP
find Files/ -type d | parallel 'mkdir -p /BKP/{}'
- Second - Copy for structure created
find Files/ -type f | parallel 'rsync -a {} /BKP/$(dirname {})'
- Great for backups!
- Can use "rsync" or "cp".
- Compare with a simple "rsync" or "cp"!
An example of this command that includes the -name arg. Show Sample Output
Allows to change 'shell' compatible files execution bit even if their name is not *.sh
My most used bash function without a doubt!
touch -t 201208211200 first ; touch -t 201208220100 last ; creates 2 files: first & last, with timestamps that the find command should look between: 201208211200 = 2012-08-21 12:00 201208220100 = 2012-08-22 01:00 then we run find command with "-newer" switch, that finds by comparing timestamp against a reference file: find /path/to/files/ -newer first ! -newer last meaning: find any files in /path/to/files that are newer than file "first" and not newer than file "last" pipe the output of this find command through xargs to a move command: | xargs -ifile mv -fv file /path/to/destination/ and finally, remove the reference files we created for this operation: rm first; rm last;
In case you ever got to many arguments using rm to delete multiple files matching a pattern this will help you
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: