Related

Denic

File comparison tools

Apache access log file

Quad Boot

Print, E-mail

Featured

Enea (Ersan Elmasa)

Name

Baby

I AM GETTING MARRIED

Fuck biology

Things I would like to do before death

Newest

MySQL database replace

Award

Graduation

Internet privacy

SSI to php

Random

Hattrick - IV.17 - Ersan 1 : 0 Barlotti

Welcome...

Camparlija

SSI to php

Audacity – Djevada Christ

Linux commands

Wednesday, November 12, 2008 11:27:11

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.



Comments

Your email address:


*Your name:


Your website:


*Please type number shown on the right side of the text box:
verification image, type it in the box

*Comment: