|
Search:
Advanced search
|
Browse by category:
|
Contact Us |
Using Awk to display a directory listing on files with spaces until the end of line |
|||||
There are situations where when performing an ls -Al displays files with spaces.
-------------------------------------------------------------------------------------------- bash-3.00# ls -al total 819568 drwxrwxrwx 2 apache www 8192 Nov 17 10:05 . drwxrwxrwx 3428 apache www 122880 Nov 18 11:30 .. -rwxrwxrwx 1 apache www 86648513 Nov 16 17:51 23568_111609_hdcp.20091116.1751.tgz -rwxrwxrwx 1 apache www 144209996 Nov 17 10:00 SELRST XRC Trace FC Port(1,1,1).trc -rwxrwxrwx 1 apache www 35514812 Nov 17 10:01 SELRST XRC Trace FC Port(1,1,2).trc -rwxrwxrwx 1 apache www 1048852 Nov 17 10:01 SELRST XRC Trace FC Port(1,1,3).trc -rwxrwxrwx 1 apache www 1048852 Nov 17 10:01 SELRST XRC Trace FC Port(1,1,4).trc -rwxrwxrwx 1 apache www 116827584 Nov 17 10:04 SELRST XRC Trace FC Port(1,3,1).trc -rwxrwxrwx 1 apache www 31989256 Nov 17 10:05 SELRST XRC Trace FC Port(1,3,2).trc -rwxrwxrwx 1 apache www 1048852 Nov 17 10:05 SELRST XRC Trace FC Port(1,3,3).trc -rwxrwxrwx 1 apache www 1048852 Nov 17 10:05 SELRST XRC Trace FC Port(1,3,4).trc -rwxrwxrwx 1 apache www 776 Nov 17 10:05 SELRST XRC Trace.tgp -------------------------------------------------------------------------------------------- To display the filename, a following does not work #ls -Al |awk '{print $9}' because it will display part of the filename: -------------------------------------------------------------------------------------------- bash-3.00# ls -Al |awk '{print $9}' 23568_111609_hdcp.20091116.1751.tgz SELRST SELRST SELRST SELRST SELRST SELRST SELRST SELRST SELRST -------------------------------------------------------------------------------------------- To display the full filename until the end of line you need to do the following: -------------------------------------------------------------------------------------------- bash-3.00# ls -Al |awk '{print substr($0, index($0,$9)) }' total 819296 23568_111609_hdcp.20091116.1751.tgz SELRST XRC Trace FC Port(1,1,1).trc SELRST XRC Trace FC Port(1,1,2).trc SELRST XRC Trace FC Port(1,1,3).trc SELRST XRC Trace FC Port(1,1,4).trc SELRST XRC Trace FC Port(1,3,1).trc SELRST XRC Trace FC Port(1,3,2).trc SELRST XRC Trace FC Port(1,3,3).trc SELRST XRC Trace FC Port(1,3,4).trc SELRST XRC Trace.tgp -------------------------------------------------------------------------------------------- |
|||||
Powered by
KBPublisher (Knowledge base software)