Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Results from "ls" command

Status
Not open for further replies.

scecilia

Programmer
Jul 8, 2002
35
US
Hello,

I am uning IRIX64. I need to do an ls - 1 (one) command in order to get a one colum listing of the contents of a non current directory:

t01:~ [119] > ls -1 /scratch/u118807/reconstruct
./
../
fr000202.rec
fr000202.sin
input_files/
input_files.tar
sin000000.rec
sin000000.sin
sym000000.raw

Now, I need to list ONLY the files with extensions .raw, .sin, or .rec as follows:

t01:~ [120] > ls -1 /scratch/u118807/reconstruct/*.{rec,raw,sin}
/scratch/u118807/reconstruct/fr000202.rec
/scratch/u118807/reconstruct/fr000202.sin
/scratch/u118807/reconstruct/sin000000.rec
/scratch/u118807/reconstruct/sin000000.sin
/scratch/u118807/reconstruct/sym000000.raw

The problem above is that I do not want the path in front of the files, I only want the filenames by themselves:

fr000202.rec
fr000202.sin
sin000000.rec
sin000000.sin
sym000000.raw

I do not want to "cd" to the directory "/scratch/u118807/reconstruct" to achieve what I want, I want to do everything from the home directory.

I tried using pipes in order to do this, but it did not work.

Any ideas?

Thanks,
--CS

 
Try:

ls -1 /scratch/u118807/reconstruct/*.{rec,raw,sin} | awk -F/ '{print $4}''

Hope this isn't too many decades late...
 
Oops...correction..

ls -1 /scratch/u118807/reconstruct/*.{rec,raw,sin} | awk -F/ '{print $4}'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top