capture specific listing in the ls -l


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting capture specific listing in the ls -l
# 1  
Old 08-21-2009
capture specific listing in the ls -l

Hi,

my desired output needs only that has *.pdf

ls -l *.pdf

error: arg list too long

so I have redirected ls -l > file.txt

therefore, I get the following details in the file

-rw-r--r-- 1 devusr devgrp 848015 Aug 11 15:13 0000795769.pdf
-rw-r--r-- 1 devusr devgrp 848492 Aug 11 15:13 0000795775.pdf
-rw-r--r-- 1 devusr devgrp 848531 Aug 11 15:14 0000795781.pdf
-rw-r--r-- 1 devusr devgrp 847842 Aug 11 15:14 0000795783.pdf
-rw-r--r-- 1 devusr devgrp 848552 Aug 11 15:14 0000795791.pdf
-rwxr-xr-x 1 devusr devgrp 88417741 Aug 21 11:42 file1.zip
-rwxr-xr-x 1 devusr devgrp 88421718 Aug 21 11:42 file2.zip
-rwxr-xr-x 1 devusr devgrp 88425125 Aug 21 11:42 file3.zip
-rw-r----- 1 devusr devgrp 1 Aug 20 13:57 samp.txt
drwxrw-rw- 2 devusr devgrp 256 Aug 1 22:02 tmp
drwxrw-rw- 2 devusr devgrp 256 Aug 17 15:44 ecs

Can I get only the lines with *.pdf to a different file

Pls advice!!
# 2  
Old 08-21-2009

Code:
grep '\.pdf$' file.txt > pdffiles.txt

Or:

Code:
ls -l | grep '\.pdf$' > pdffiles.txt

# 3  
Old 08-21-2009
Code:
ls -l *.pdf > "pdffiles.txt"

# 4  
Old 08-21-2009
Great....working fine

Thanks for your reply and answer Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

2. AIX

Capture whoami log on a specific command

// AIX 6.1 TL8 Please advise on how to capture whoami log or the user and time info into a log file (i.e. /tmp/cmdcapture.log) whenever users are executing a certain command(s) so that I can keep the single log history (for all users) of who did what. The command(s) I need to monitor are a... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

3. UNIX for Dummies Questions & Answers

[Solved] How to remove listing of current user cmd from ps -ef listing?

Hi All, Could you please help to resolve my following issues: Problem Description: Suppose my user name is "MI90". i.e. $USER = MI90 when i run below command, i get all the processes running on the system containing name MQ. ps -ef | grep MQ But sometimes it lists... (8 Replies)
Discussion started by: KDMishra
8 Replies

4. Shell Programming and Scripting

Capture specific fields in file

Dear Friends, I have a file a.txt 1|3478.12|487|4578.04|4505.5478|rhfj|rehtire|rhj I want to get the field numbers which have decimal values output: Fields: 2,4,5 Plz help (6 Replies)
Discussion started by: i150371485
6 Replies

5. UNIX for Dummies Questions & Answers

Listing files without specific expression in the file

I am running Ubuntu 11.10 I have the following files. geo2503r05690585.html geo2503r06020612.html geo2503r06250641.html geo2503r06490658.html geo2503r06830686.html geo2503r05860601.html geo2503r06130624.html geo2503r06420648.html geo2503r06590682.html ... (4 Replies)
Discussion started by: kristinu
4 Replies

6. Shell Programming and Scripting

Request for shell script for listing directories, subdirs containing specific files.

I'm looking for a script which outputs the list of directories and sub directories from root level consisting of specific files. For instance I want shell script to list all the directories and subdirectories containing .txt files.:wall: (4 Replies)
Discussion started by: super210
4 Replies

7. Shell Programming and Scripting

Script for listing specific filename in 3 directory

I used to work in perl but I would like to try now bash. Here's my problem I wanted to search for specific filename (ls -ltrh) on 3 directories.. Example ls -ltrh | grep "string" /dir1 /dir1/dir2 /dir1/dir2/dir3 I wanted to get the result to be copied on a different directory. Sample... (2 Replies)
Discussion started by: lhareigh890
2 Replies

8. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

9. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question