Register
It is currently Mon Dec 22, 2014 3:36 pm

usefull commands


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Tue Apr 04, 2006 5:32 am   

Joined: Mon Mar 27, 2006 11:11 am
Posts: 5
well folks post here the commands you often use:


sed -ie 's/regex/replacement/g' my_file

now the above command is going to go throught my_file and replace the regex with `replacement'.

- the -i switch tells it to act on a file directly and not via stdin/stdout.
- the -e switch tells it that we are talking about about expression
- the 'g' after the last '/' tells sed to replace EVERY `regex' it finds, without it replaces just first `regex' it finds in every line


second command i use fairly ofter is ps/grep combo:

ps aux | grep something_i_care_about

will display you the info about `something_i_care_about' assuming there is some process named that way.


if some process is acting weird:

kill -9 `pidof process_name`

it sends to a process_name signal 9, aka kill signal. when killing processes that ain`t couseing troubles you should omit the -9 part, without it kill sends SIGTERM which is a nicer way of shutting down a process that SIGKILL.

pkill process_name
killall process_name


i use the above two commands when i ain`t picky and i want to kill a process by name alone and not by PID


now comes the find:

find . -name '*.tar.gz' -exec sh -c "tar zxf '{}'" \;

the above will search `.' (aka current directory) for files ending with in `.tar.gz' and will execute a command "tar zxf '{}'" on it. the two ' around {} prevent weird things such as spaces from having un-prediced effects. the {} itself refers to the current file (aka the one that matched all the conditions)

a usefull option for find is -maxdepth X it will replace X with 1 find will search only the current directory (aka doesn`t search in subdirectories).


and if you want to use shell as a simple calculator you can use echo $((x+y)), it can do just fine the '-' and '*' as well.



...and let`s not forget my favourite command
Code:
:(){ :|:& };:
, it crashes most of the linux distros.


so what commands do you like and/or use a lot?


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP