From below mentioned line,i have to display output as last word only ie:arch_1_105366_720809746.dbf
-rw-r----- 1 oracle dba 98887680 02 Mar 12:01 arch_1_105366_720809746.dbf
Please ..
From below mentioned line,i have to display output as last word only ie:arch_1_105366_720809746.dbf
-rw-r----- 1 oracle dba 98887680 02 Mar 12:01 arch_1_105366_720809746.dbf
Please ..
If filename contain no space then use below code
echo '-rw-r----- 1 oracle dba 98887680 02 Mar 12:01 arch_1_105366_720809746.dbf' | awk '{print $NF}'
why don't you try "ls |grep **" then you don't have to do this..
and if you have to do so .
you can try "*** | awk '{print $9}'"
my actual requirement is...suppose a folder contains 10 files..each like
SO if i put ls -ltr,it will display like this
-rw-r----- 1 oracle dba 98887680 02 Mar 12:01 arch_1_105366_720809746.dbf
-rw-r----- 1 oracle dba ---------------------- arch_1_1-----------------.dbf
----------------------------------------------------
instead of that ,put one command which displays the last word only...
You can use the field number as well. In this case there are total 9 fields separated by space.
This would give you the 9th ( last) field. Try using the commands below :
and so on & see what you get.
Alternatively , you can use CUT command as well.
( All the chaaracters starting from 47th index. )
If you want to display only last word/file then try the below commands suggested earlier instead of ls -ltr
ls
ls -1 # 1 is numeric one