awk
Print characters less than 3
................
$ ls
Applications Network Users bin dev home net private tmp var
Library System Volumes cores etc mach_kernel opt sbin usr
$ ls | awk 'length($0) < 4'
bin
dev
etc
net
opt
tmp
usr
var
................
Print or cut only selected column
$ ls -l
total 16
-rw-r--r--+ 1 sasi staff 39 Feb 18 2014 index.html.en
-rw-r--r--+ 1 sasi staff 40 Feb 18 2014 ip.php
$ ls -l | awk '{print $2}'
16
1
1
$ ls -l | awk '{print $2, $4}'
16
1 staff
1 staff
Xargs:
Find and remove / copy / move
$ find /path -iname 'search string' | xargs 'action'
i- ignore case
Example:
$ find /root -iname 'asterisk' | xargs rm -rf
This will find and remove all the files and dir matching with asterisk
Print characters less than 3
................
$ ls
Applications Network Users bin dev home net private tmp var
Library System Volumes cores etc mach_kernel opt sbin usr
$ ls | awk 'length($0) < 4'
bin
dev
etc
net
opt
tmp
usr
var
................
Print or cut only selected column
$ ls -l
total 16
-rw-r--r--+ 1 sasi staff 39 Feb 18 2014 index.html.en
-rw-r--r--+ 1 sasi staff 40 Feb 18 2014 ip.php
$ ls -l | awk '{print $2}'
16
1
1
$ ls -l | awk '{print $2, $4}'
16
1 staff
1 staff
Xargs:
Find and remove / copy / move
$ find /path -iname 'search string' | xargs 'action'
i- ignore case
Example:
$ find /root -iname 'asterisk' | xargs rm -rf
This will find and remove all the files and dir matching with asterisk
No comments:
Post a Comment