This is the way how you can find header and cpp files in the same time.
search ubuntu's remote package source repositories for a specific program to see which package contains it Show Sample Output
Recursively rename .JPG to .jpg using standard find and mv. It's generally better to use a standard tool if doing so is not much more difficult.
To apply only to dirs:
chmod 755 $(find . -type d)
Use -R parameters for recursive walk.
+ at the end means that many filenames will be passed to every chmod call, thus making it faster. And find own {} makes sure that it will work with spaces and other characters in filenames.
.flac is the filetype. /Volumes/Music/FLAC is the destination. Show Sample Output
This is usefull to diff 2 paths in branches of software, or in different versions of a same zip file. So you can get the real file diff. Show Sample Output
The output format is given by the -printf parameter: %T@ = modify time in seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. Mandatory, hidden in the end. %TY-%Tm-%Td %TH:%TM:%.2TS = modify time as YYYY-MM-DD HH:MM:SS. Optional. %p = file path Refer to http://linux.die.net/man/1/find for more about -printf formatting. ------------------------ sort -nr = sort numerically and reverse (higher values - most recent timestamp - first) head -n 5 = get only 5 first lines (change 5 to whatever you want) cut -f2- -d" " = trim first field (timestamp, used only for sorting) ------------------------ Very useful for building scripts for detecting malicious files upload and malware injections. Show Sample Output
syntax follows regular command line expression. example: let's say you have a directory (with subdirs) that has say 4000 .php files. All of these files were made via script, but uh-oh, there was a typo! if the typo is "let's go jome!" but you meant it to say "let's go home!" find . -name "*.php" | xargs perl -pi -e "s/let\'s\ go\ jome\!/let\'s\ go\ home\!/g" all better :) multiline: find . -name "*.php" | xargs perl -p0777i -e 's/knownline1\nknownline2/replaced/m' indescriminate line replace: find ./ -name '*.php' | xargs perl -pi -e 's/\".*$\"/\new\ line\ content/g' Show Sample Output
Find all files that contain string XXX in them, change the string from XXX to YYY, make a backup copy of the file and save a list of files changed in /tmp/fileschanged.
This command is somewhat similar to 'nice', but constrains I/O usage rather than CPU usage. In particular, the '-c3' flag tells the OS to only allow the process to do I/O when nothing else is pending. This dramatically increases the responsiveness of the rest of the system if the process is doing heavy I/O. There's also a '-p' flag, to set the priority of an already-running process.
Works in Ubuntu, I hope it will work on all Linux machines. For Unixes, tail should be capable of handling more than one file with '-f' option. This command line simply take log files which are text files, and not ending with a number, and it will continuously monitor those files. Putting one alias in .profile will be more useful.
A simple "ls" lists files *and* directories. So we need to "find" the files (type 'f') only. As "find" is recursive by default we must restrict it to the current directory by adding a maximum depth of "1". If you should be using the "zsh" then you can use the dot (.) as a globbing qualifier to denote plain files: zsh> ls *(.) | wc -l for more info see the zsh's manual on expansion and substitution - "man zshexpn". Show Sample Output
this will show the names of the deleted directories, and will delete directories that only no files, only empty directories.
You can also use, $ find . -depth -type d -exec rmdir {} \; 2>/dev/null
Put the positive clauses after the '-o' option.
counts the total (recursive) number of files in the immediate (depth 1) subdirectories as well as the current one and displays them sorted. Fixed, as per ashawley's comment Show Sample Output
Searches your $PATH for whatever you substitute for bash, though not sure if this will work if you substitute a different shell for bash! Show Sample Output
-L tells find to follow symbolic links, so -type l will only return links it can't follow (i.e., those that are broken).
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: