Finds all files of a certain name and reports all line with the string. Very simple. Show Sample Output
No need for -l and the output can be sent directly into another function expecting directory names. Show Sample Output
xargs deals badly with special characters (such as space, ' and "). To see the problem try this: touch important_file touch 'not important_file' ls not* | xargs rm Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.
You WILL have problems if the files have the same name.
Use cases: consolidate music library and unify photos (especially if your camera separates images by dates).
After running the command and verifying if there was no name issues, you can use
ls -d */ | sed -e 's/^/\"/g' -e 's/$/\"/g' | xargs rm -r
to remove now empty subdirectories.
This is a slight variation of an existing submission, but uses regular expression to look for files instead. This makes it vastly more versatile, and one can easily verify the files to be kept by running ls | egrep "[REGULAR EXPRESSION]"
newly downloaded videos
goyoutube
random
goyoutube rand
This command assumes you've already downloaded some YouTube .mp4 or .flv video files via other means. Requires 'shuf', or your own stdin shuffler.
find and normal files and list them sorting with modification time without group l: with detailed information t: sort with modification time r: reverse order h: show file's size in human-readable format, such as K(kilobytes), M(megabyes) etc. g: do not show group Show Sample Output
the command will not include hidden files Show Sample Output
This will list all symlinks that are directories under the current directory. This will help you distinguish them from regular files.
Really, you deserve whatever happens if you have a whitespace character in a file name, but this has a small safety net. The truly paranoid will use '-i'.
Tail all logs that are opened by all java processes. This is helpful when you are on a new environment and you do not know where the logs are located. Instead of java you can put any process name. This command does work only for Linux.
The list of all log files opened by java process:
sudo ls -l $(eval echo "/proc/{$(echo $(pgrep java)|sed 's/ /,/')}/fd/")|grep log|sed 's/[^/]* //g'
Calculate foldersize for each website on an ISPConfig environment. It doesn't add the jail size. Just the "public_html". Show Sample Output
This command, when run from the directory containing "filename", will remove the file and any hard or symbolic links to the file.
If you have a folder with thousand of files and want to have many folder with only 100 file per folder, run this. It will create 0/,1/ etc and put 100 file inside each one. But find will return true even if it don't find anything ... Show Sample Output
urldecode files in current directrory
-l for long list, -r for recursive, -a for display of hidden files, and -t for modification date
Escapes spaces in paths.
Replace the head -1 with head -n that is the n-th item you want to go to. Replace the head with tail, go to the last dir you listed. You also can change the parameters of ls.
Sort by time and Reverse to get Ascending order, then display a marker next to the a file, negate directory and select only 1 result Show Sample Output
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: