Wednesday, 16 October 2013

No-brainer tips for navigating large software projects in Unix/ Linux

Here are the two commands without which I could not live when working on large projects:

grep -rn 'some_text' . [--exclude=*.some_extension] [--include=*.some_extensions] [--color=auto]

Searches for some_text in all the files in the current directory (recursively) and displays the file name and the line number where the text was found (-n). Optionally, it can exclude/ include certain file patterns, and colorize the output.

find . -name '*some_text*' [-ls]

Searches for all files having some_text in their name (see man find for other options); -ls will output the files' details like, well, ls does.

Bonus: tail -fn 10 will continuously output the last ten (or how many you want) lines of a file, and is useful for watching log files.

No comments:

Post a Comment