I am updating this post when I find a useful linux command. And keep this post, just for my reference and for anyone who may find it helpful.
- Clear | Truncate the data in a file without opening.
truncate -s 0 <file name>
- Find files which has given text in given location
grep -nrwl -e <"text to find">
n: line number
r : recursive
w: match the whole word, if search for a part of the word omit w
l : show the file only - Create folder tree
mkdir -p level_1/{level_2_a,level_2_b}
- Find and delete file | folder
find . -name ".project" -exec rm -r "{}" \;
- List all the files which are edited in the given date range
find repository/conf/ -type f -name "*.xml" -newermt 2015-05-11 ! -newermt 2015-06-07
- Print the last n number of lines of a file.
tail -n file_name
- Find and replace the text of all the files recursively in given location.
grep --include={*.java,*.xml} -rnl './' -e "find-text" | xargs -i@ sed -i 's/find-text/replace-text/g' @