Unix Command for listing files containing one text but not other.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unix Command for listing files containing one text but not other.
# 1  
Old 11-19-2013
Unix Command for listing files containing one text but not other.

Hi,

I want to list all files present in directory those contains one specific word but exclude other.
If possible suggest unix commands instead of script to do so.

e.g.
List all files name from directory which are having "PROMOTION" word but not "LEN_PROMOTION".


Thanks

Last edited by gauravgautam135; 11-19-2013 at 08:07 AM.. Reason: mentioned unix specific command needed
# 2  
Old 11-19-2013
Do any of the files have BOTH strings - what output do you want for that? -- do we include that file or not?
# 3  
Old 11-19-2013
Jim,

I need only those files which are having "PROMOTION" keyword but if any of these files have "LEN_PROMOTION" then exclude that file.

I hope you understand what i am trying to convey.
# 4  
Old 11-19-2013
you can search the string/keyword with grep and use | grep -v ... for what is to be rejected...
# 5  
Old 11-20-2013
Facebook Direct command

For long listing
Code:
ls -lrt *PROMOTION* | grep -v LEN

For just FIlename
Code:
ls *PROMOTION* | grep -v LEN


Last edited by Franklin52; 11-20-2013 at 10:47 AM.. Reason: Please use code tags, thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Listing only the files under a directory from the result of find command

Hi, I have a main folder 'home'. Lets say there is a folder 'bin' under 'home'. I want to check the list of files under subdirectories present under the /bin directory created in the last 24 hours. I am using the following find command under home/bin directory: find . -mtime -1 -print ... (3 Replies)
Discussion started by: DJose
3 Replies

2. UNIX for Dummies Questions & Answers

Listing no. of files in UNIX with common prefix name

Hi, I am entirely new to Unix, need your help to perform certain actions in unix: Can anyone please tell me how to list the number of files in UNIX with Common prefix name. "I want just the number of files and not the names of files". Thanks (12 Replies)
Discussion started by: Hitesh1008
12 Replies

3. Solaris

SFTP Command Help - listing files

Ok I am just going to explain what I am running step by step sftp user@hostname sftp > ls < when I run the command "ls" I get a long listing the old version, on the new version I get a short listing how can I change my new version to give me long listing by default (1 Reply)
Discussion started by: slufoot80
1 Replies

4. UNIX for Dummies Questions & Answers

Listing files in a Unix Directory ending with .....

Hi Unix Gurus, I need to list all files in a Unix Directory which either end with a .pdf or .rtf and they should be case insensitive ie .Pdf , .pDF , .RtF etc are also possible. How can i accomplish this with with a ls command ? If not then a find command. (6 Replies)
Discussion started by: pchegoor
6 Replies

5. UNIX for Dummies Questions & Answers

Long listing of files using find command on remote server via SSH

Hi , I am trying to find some files on a remote machine using the find command. >ssh -q atukuri@remotehostname find /home/atukuri/ -name abc.txt /home/atukuri/abc.txt The above command works fine and lists the file, but if I want to do a long listing of files (ls -l) its not working . ... (2 Replies)
Discussion started by: atukuri
2 Replies

6. UNIX for Dummies Questions & Answers

find command -- listing files twice

I noticed the other day that after i used the find command to search for some files, the computer listed them twice -- first with just the names of the files (meaning ./(then the individual file names), then with the directory name, followed by the file names (./directory name/file name). I was... (2 Replies)
Discussion started by: Straitsfan
2 Replies

7. UNIX for Dummies Questions & Answers

listing executable files in unix.

How to list out the files which are not accessed for the last n days? and How to list out all the executable files in a directory? can anyone help me on the above? Thanks in advance. (3 Replies)
Discussion started by: venkatesht
3 Replies

8. UNIX for Dummies Questions & Answers

ls command for listing the number of files

I've searched the man page for an option for the ls command to print the number of files in a directory. I'm moving files and folders around and thought a count of files would be a quick way to determine if I was missed one somewhere. Some "unix's" shells do this I think... maybe linux... ... (4 Replies)
Discussion started by: jimmyc
4 Replies

9. Solaris

TAR command , listing backed up files

I've backed up several files to tape using tar, and wish to list those that have backed up. % tar cvf /dev/rmt/2un /s_1/oradata/pgpub/config.ora a /s_1/oradata/pgpub/config.ora 2 tape blocks But when I go to list the files: % tar tvf /dev/rmt/2un tar: tape read error What am I... (3 Replies)
Discussion started by: FredSmith
3 Replies

10. Filesystems, Disks and Memory

Sun UNIX Files & Folders listing

Hi guys, i'm new to UNIX and only know a small amout about it, but have just had some changes at work which now require me to interact with and work on SUN Unix systems often. I have reasonable knowledge of PC's but hope that you will be able to help me with these questions. Part1. I would like... (3 Replies)
Discussion started by: Scrat
3 Replies
Login or Register to Ask a Question