[LEFT]I have a file whose contents are
dir1/dir2/dir3/file1.x
dir1/dir2/dir3/file2.y
dir1/dir2/dir3/file3.z
dir1/dir2/dir/file4.a
etc.
How can I use 'cut' command to get x, y, z, a and redirect it to a new file.
i.e., how can I use 'cut' command to supress all the characters before '/' and send x,y,z and a to another file.
[/LEFT]
What have you tried?
i tried echo ${failhost#*.} in a script but didnt work
try awk..sed.. cut.. etc etc..
awk -F"." '{print $2}' filename
sed 's/\(.*\)\.\(.*\)/\2/g' filename
cut -d"." -f2 filename
Thanks Vidyadhar.
That works....
With internal shell substring functions:
$ var="dir1/dir2/dir3/file1.x"
$ echo ${var##.}
x
$
$ echo ${var##*/}
file1.x
$