For this example, all files in the current directory that end in '.xml.skippy' will have the '.skippy' removed from their names.
I constantly need to work on my local computer, thus I need a way to download the codeigniter user guide, this is the wget way I figured.
We normally get tasks in which one has to sort a data file according to some column. For a single file say foo, we would use sort -k 3 foo >tmp && tmp foo The for loop is useful when we have to do it on a number of files.
This heavy one liner gets all the files in the "/music/dir/" directory and filters for non 44.1 mp3 files. After doing this it passes the names to sox in-order to re-sample those files. The original files are left just in case.
without sed, but has no problems with files with spaces or other critical characters
Use find's built-in "exec" option to avoid having to do any weirdness with quoting.
cd into the directory that contains the file. this is just the usual move command but shortcut'd. say you wanted to move a photo img1.png from ~/photos/holidayphotos into the parent directory which is ~/photos command would be: ~/photos/holidayphotos$ mv img1.png .. I use Ubuntu so this'll work in debian but not sure what else.
I needed this for wine.
all files in the directory get moved, in doing so the new name of the file is the original name with out spaces (using translate command)
Search in all html files and remove the lines that 'String' is found.
doesnt require knowing the password to pdf Show Sample Output
For those files in current folder that would be shown in `ls *ext`, for some extension ext, move/rename that file removing the .ext suffix from the file name. It uses Bash's parameter substitution, as seen in http://tldp.org/LDP/abs/html/parameter-substitution.html#PCTPATREF (for analog use in prefix, see http://tldp.org/LDP/abs/html/parameter-substitution.html#PSOREX2 )
Will move in that case every file in the current folder older than 30 days to the "old" folder Replace "mv $i old/" by any command such as rm / echo to do something different.
I have often file like this 01 - file.file 02 - file.file 03 - file.file I rename all with this command for f in * ; do mv -- "$f" "${f/[0-9][0-9] \- /}" ; done then it looks like this file.file file.file file.file etc
Yeah, there are many ways to do that. Doing with sed by using a for loop is my favourite, because these are two basic things in all *nix environments. Sed by default does not allow to save the output in the same files so we'll use mv to do that in batch along with the sed. Show Sample Output
Prepends all directory items with "prependtext"
I don't like TABs in sources files because in case of mixture of TABs and spaces they looks in different editors. Even worse mixing TABs and spaces could be a problem when you use Python.
Recursively find php files and replace tab characters with spaces. Options: "\*.php" -- replace this with the files you wish to find "expand" -- replace tabs with spaces (use "unexpand" to replace spaces with tabs) "-t4" -- tabs represent 4 spaces Note: The IFS="" in the middle is to prevent 'read' from eating leading/trailing whitespace in filenames.
This example uses the -exec option to move all matching files into a backup directory
In my job I often have to deal with moving 100,000 files or more. A mv won't do it because there are too many. This will move everything in the current directory to the target path.
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: