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?