Uses parallel processing Reiteration of my earlier command https://www.commandlinefu.com/commands/view/15246/convert-entire-music-library Usage lc Old_Directory New_DIrectory Old_Format New_Format lc ~/Music ~/Music_ogg mp3 ogg Show Sample Output
When I go to change a configuration file I always like to make a backup first. You can use "cp -p" to preserve the modification time, but it gets confusing to have file.prev, file.prev2, etc. So I like to add a YYMMDD suffix that shows when the file was last changed. "stat -c %Y" gives you the modification time in epoch seconds, then "date -d @" converts that to whatever format you specify in your "+format" string. Show Sample Output
If your `date` command has `-r` option, you don't need `stat`
Change ~/tmp to the destination directory, such as your mounted media. Change -n20 to whatever number of files to copy. It should quit when media is full. I use this to put my most recently downloaded podcasts onto my phone.
To check if the table-of-content in a LaTeX document is up-to-date, copy it to a backup before running LaTeX and compare the new .toc to the backup. If they are identical, it is updated. If not, you need to run LaTeX again.
Today I needed to choose an icon for an app. My simpler way: put all of /usr/share/icons in myicons folder and brows'em with nautilus. Then rm -r 'ed the entire dir. Show Sample Output
In other way of xargs, only with find -exec
dir1 and all its subdirs and subdirs of subdirs ... but *no files*
will be copied to dir2 (not even symbolic links of files will be made).
To preserve ownerships & permissions:
cp -Rps dir1 dir2
Yes, you can do it with
rsync -a --include '*/' --exclude '*' /path/to/source /path/to/dest
too, but I didn't test if this can handle attributes correctly
(experiment rsync command yourself with --dry-run switch to avoid
harming your file system)
You must be in the parent directory of dir1 while executing
this command (place dir2 where you will), else soft links of
files in dir2 will be made. I couldn't find how to avoid this
"limitation" (yet). Playing with recursive unlink command loop
maybe?
PS. Bash will complain, but the job will be done.
Show Sample Output
This is a simple case of recursing through all directories, adding the '.bak' extension to every file. Of course, the 'cp $file $file.bak' could be any code you need to apply to your recursion, including tests, other functions, creating variables, doing math, etc. Simple and clean recursion.
Copy the file with the given .extension at the source file's location. Eliminates the typing of long paths again and again. Show Sample Output
-t, --target-directory=DIRECTORY (copy all SOURCE arguments into DIRECTORY).
./* is for copying files starting with - .[!.]* is for copying hidden files and avoiding copying files from the parent directory. ..?* is for copying files starting with .. (avoids the directory ..) /path/to/dir the path to the directory where the files should be copied Can also be used as a script. Input argument is /path/to/dir in tcsh, replace .[!.]* with .[^.]*
search the newest *.jpg in the directory an make a copy to newest.jpg. Just change the extension to search other files. This is usefull eg. if your webcam saves all pictures in a folder and you like the put the last one on your homepage. This works even in a directory with 10000 pictures.
It will create a backup of the filename. The advantage is that if you list the folder the backups will be sorted by date. The command works on any unix in bash. Show Sample Output
I used this command to recursively gather all mp3 files that were previously imported into their own directories (sorted by band name) in Songbird.
This command copies all filenames in the current dir and subdirs that end in .mp3 regardless of case (also matches .MP3 .mP3 and .Mp3) It copies all the files to the "mp3" folder in your home directory. If you want to see the files that are beeing copied, replace "cp {}" with "cp -v {}"
copy some file from xx.m3u to target folder
Maybe it could work for any music player if you change "audacious2" with the string you see in `ps aux` for your player. Needs testing in different systems. Show Sample Output
buf myfile.txt
This is useful when you are making small but frequent changes to a file. It keeps things organised and clear for another administrator to see what changed and at what time. An overview of changes can be deduced using a simple:
ls -ltr
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: