Monday 15 August 2011

Tips

sudo !!

Run the last command as root


cd -


change to the previous working directory

^
msRoot:~ ioannis$ echo "no typozs"
no typozs
msRoot:~ ioannis$ ^z
echo "no typos"
no typos
msRoot:~ ioannis$

runs the last command -z :D




cp filename{,.bak}
or

cp file.txt{,.bak}
quickly backup or copy a file with bash


> file.txt

Empty a file
msRoot:~ ioannis$ echo "ena dio tria" > test.txt
msRoot:~ ioannis$ cat test.txt
ena dio tria
msRoot:~ ioannis$ > test.txt
msRoot:~ ioannis$ cat test.txt
msRoot:~ ioannis$


echo "ls -l" | at midnight

msRoot:~ ioannis$ echo "ls -l" | at midnight
job 3 at Tue Aug 16 00:00:00 2011
msRoot:~ ioannis$


sh files with params
in file myfile.sh
---------------
#!/bin/sh
echo ${1}
---------------


msRoot:~ ioannis$ chmod 777 myfile.sh
msRoot:~ ioannis$ ./myfile.sh testing
testing
msRoot:~ ioannis$


.
Insert the last argument of the previous command

msRoot:~ ioannis$ ./myfile.sh my_params
my_params
msRoot:~ ioannis$ my_params <-- .



!!:gs/foo/bar
replace last commnad foo by bar :)

msRoot:~ ioannis$ ls -h
msRoot:~ ioannis$ !!:gs/-h/-la
ls -la
total 37


curl ifconfig.me

msRoot:~ ioannis$ curl ifconfig.me
144.131.30.185
msRoot:~ ioannis$ curl ifconfig.me/ua
curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
msRoot:~ ioannis$ curl ifconfig.me/host
CPE-144-131-30-185.lns10.lon.bigpond.net.au
msRoot:~ ioannis$

ctrl-l
Clear the terminal screen

(cd Books && ls)
msRoot:~ ioannis$ (cd Books && ls)
Jump to a directory, execute a command and jump back to current dir

32713.pdf
Google Maps Hacks
IELTS.Pack
Korrigierte Pr


awk

msRoot:~ ioannis$ echo 'Expires: 10/May/2009' | awk -F':' '{ print $2}'
10/May/2009
msRoot:~ ioannis$ echo 'Expires: 10/May/2009' | cut -d: -f2
10/May/2009
msRoot:~ ioannis$






No comments:

Post a Comment