Thursday, April 11, 2013

Useful One liners.


Excellent example of appending the "/home/" in front of all the users name in a file
which has 3222 records.


%s/^/\/home\//g


----------------------------------------------


 df -hl | awk '{ print $1 "; " "\t" $5}' | sort -n

------------------------------------------

AUTOENV=/opt/CA/WorkloadAutomationAE/autouser.PRD/autosys.sh.trs20

--------------------------------------------

Following command will create 1 GB File system

dd if=/dev/zero of=test.iso2 bs=1024 count=1000000

--------------------------------------------


Following command will count the file size in GB/MB i.e. in human readable form:

for i in `du -sh * |sort -n |cut -f2`; do du -sh $i; done

--------------------------------------------

# tar -xvf etc.tar -C test/  ---> Untar the tarball in test directory.

# tar -tvf etc.tar ---> To view the tarball contents without actually extracting.

--------------------------------------------

Use dd command to create an ISO image

# if=/dev/cdrom of=/datacdimg.iso

thats it!

--------------------------------------------

# cut -d: '' -f1 passwd ---> Will print first column

# cut -d: -f1,6 passwd ---> will extract user &  home directory.

--------------------------------------------
awk:bash

awk -F':' '{print $1}' passwd  ---> This will get the first column separated by : ex. passwd file.

No comments: