Things I would like to do before death
Not long ago I used linux exclusively. Back then I have had little cheat sheet for some commands I used often, in a case I forget about them.
They sure can come in handy nowadays since I use Windows 90% of the time, and old man like myself can sure forget about them.
So, here they go!
To replace text in multiple files within folder:
grep -rl OLDSTRING . | xargs perl -pi -e ’s/OLDSTRING/NEWSTRING/’
Example: grep -rl ersan . | xargs perl -pi -e ’s/ersan/ersano/’
To find text in multiple files recursively in folder:
find . -exec grep -q "TEXTTOSEARCH" '{}' \; -print
Example: find . -exec grep -q "ersano" '{}' \; -print
To search for text and put it in new file:
cat SEARCHTHISFILE | grep "SEARCHFORTHISTEXT" > NEWFILEWITHSEARCHEDTEXT
Example: cat ersan.txt | grep "ersano" > ersanoishere.txt
To tar:
tar cvzf TARFILE ORIGINALFILE
Example: tar cvzf ersan.tar.gz ersan.txt
To untar:
tar xzvf TARFILE
Example: tar xzvf ersan.tar.gz
Copying file from remote location:
scp USERNAME@REMOTESERVER:PATHTOFILE LOCALPATH
Example: scp ersan@ersano.com:/home/ersan/ersano.txt /home/ersan/
Copying file to remote location:
scp FILETOCOPY USERNAME@REMOTESERVER:PATHTOFILE
Example: scp ersano.txt ersan@ersano.com:/home/ersan/
Copy (local) content of entire directory is:
cp -f /COPYFROM/* /COPYTO/
Example: cp -f /home/ersan/* /home/ersan/backup/
Of course, these are commands that were useful to me, they may be useless to you. You may want, need, to check man pages for more detailed info.