from 1.ogg 2.ogg 3.ogg 10.ogg 11.ogg to 01.ogg 02.ogg 03.ogg 10.ogg 11.ogg
Used for moving stuff around on a fileserver
That is an alternative to command 8368.
Command 8368 is EXTREMELY NOT clever.
1) Will break also for files with spaces AND new lines in them AND for an empty expansion of the glob '*'
2) For making such a simple task it uses two pipes, thus forking.
3) xargs(1) is dangerous (broken) when processing filenames that are not NUL-terminated.
4) ls shows you a representation of files. They are NOT file names (for simple names, they mostly happen to be equivalent). Do NOT try to parse it.
Why? see this :http://mywiki.wooledge.org/ParsingLs
Recursive version:
find . -depth -name "*foo*" -exec bash -c 'for f; do base=${f##*/}; mv -- "$f" "${f%/*}/${base//foo/bar}"; done' _ {} +
Show Sample Output
or, to process a single directory:
for f in *; do mv $f `echo $f |tr '[:upper:]' '[:lower:]'`; done
Show Sample Output
Useful for backing up old files, custom logs, etc. via a cronjob. Show Sample Output
I realize there's a few of these out there, but none exactly in this form, which seems the cleanest to me
Maybe simpler, but again, don't know how it will work with space in filename.
Use this command if you want to rename all subtitles for them to have the same name as the mp4 files. NOTE: The order of "ls -1 *.mp4" must match the order of "ls -1 *.srt", run the command bellow to make sure the *.srt files will really match the movies after run this command: paste -d:
This is my first attempt at converting all HTML files to UTF-8 file encoding, including all subfolders. Theres probably a much more compact way to do it, but I'm quite proud of it with my windows background ;)
Good old bracket expansion :-) For large numbers of files, "rename" will spare you the for-loop, or the find/exec...
This will convert filenames from uppercase to lowercase. I find this useful after downloading images from my digital camera. This works for English, but other languages may need something slightly more complex like this:
for i in *; do mv "$i" "$(echo $i|tr [:upper:] [:lower:])"; done
Also, the quote marks aren't necessary if your filenames don't contain spaces.
Useful if you have a list of images called 1 2 3 4 and so on, you can adapt it to rewrite it as 4 (in this example) 0-padded number. Show Sample Output
Sometimes in a hurry you may move or copy a file using an already existent file name. If you aliased the cp and mv command with the -i option you are prompted for a confirmation before overwriting but if your aliases aren't there you will loose the target file! The -b option will force the mv command to check if the destination file already exists and if it is already there a backup copy with an ending ~ is created.
FILENAME=nohup.out mv -iv $FILENAME{,.$(stat -c %Y $FILENAME)} does it help ? Show Sample Output
It helps you save a lot of writing :-) Show Sample Output
Only tested on Linux Ubunty Hardy. Works when file names have spaces. The "-maxdepth 2" limits the find search to the current directory and the next one deeper in this example. This was faster on my system because find was searching every directory before the current directory without the -maxdepth option. Almost as fast as locate when used as above. Must use double quotes around pattern to handle spaces in file names. -print0 is used in combination with xargs -0. Those are zeros not "O"s. For xargs, -I is used to replace the following "{}" with the incoming file-list items from find. Echo just prints to the command line what is happening with mv. mv needs "{}" again so it knows what you are moving from. Then end with the move destination. Some other versions may only require one "{}" in the move command and not after the -I, however this is what worked for me on Ubuntu 8.04. Some like to use -type f in the find command to limit the type. Show Sample Output
Need to have rc iso pre-downloaded before running command.
Checks if a web page has changed. Put it into cron to check periodically. Change http://www.page.de/test.html and mail@mail.de for your needs.
if you use disk-based swap then it can defeat the purpose of this function.
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: