in csh
set x = "/home/usr/dir1/file1"
if i do:
echo $x | awk -F\/ '{print $NF}'
will result to:
"file1"
how do i invert the output to:
"/home/usr/dir1"
in csh
set x = "/home/usr/dir1/file1"
if i do:
echo $x | awk -F\/ '{print $NF}'
will result to:
"file1"
how do i invert the output to:
"/home/usr/dir1"
Why use awk?
dirname $x
anyway to use awk:
echo $x|awk -F\/ '{for (i=1;i<=NF-2;i++)printf("%s/",$i);printf("%s\n",$i)}'
In csh:
% set x = "/home/usr/dir1/file1"
% echo $x:h
/home/usr/dir1