Exclude files in ls


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exclude files in ls
# 1  
Old 06-24-2014
Exclude files in ls

Hi,

I need to exlucde the files which are present in exclude.txt from a directory

Code:
exlcude.txt
AUZ.txt
AUZ.chk
NZ.txt
NZ.chk

tried with below code but not working
Code:
 
ls -ltr | grep -v `cat exclude.lst`

# 2  
Old 06-24-2014
Try
Code:
ls -ltr | grep -vFf exclude.txt

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 06-24-2014
Yeah the above on worked, will it be possible to exclude the files if i am having a file like below

Code:
exclude.txt

AUZ.txt AUZ.chk
NZ.txt NZ.chk

# 4  
Old 06-24-2014
If you are using bash or ksh93 you could try:
Code:
ls -ltr | grep -vFf <(xargs -n1 < exclude.txt)

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 06-24-2014
yeah but would this same work if the file contains data with delimited separated

Code:
AUZ.txt,AUZ.chk,xyz
NZ.txt,NZ.chk,xxzz

This should exclude only
Code:
AUZ.txt
AUZ.chk
NZ.txt
NZ.chk


Last edited by Scrutinizer; 06-24-2014 at 11:36 AM.. Reason: Additional CODE tags
# 6  
Old 06-24-2014
No, that would not, since the format of the file is one of the factors that determine the solution. If it keeps changing then the solution would need to change also. Please be clear about the format of the file and explain which part should be used, for example..
# 7  
Old 06-24-2014
The file format can be like below

Code:
AUZ.txt,AUZ.chk,xyz
NZ.txt,NZ.chk,xxzz

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to Exclude Files That Still On Transfer..

Hi. I want to schedule a job at some directory will several files in it. But there maybe a situation whereby some of the files at the point of the schedule are still transferring during that time. So I want to skip those files from being processed. Two method that come to my mind: 1.... (5 Replies)
Discussion started by: aimy
5 Replies

2. Shell Programming and Scripting

Exclude files in gzip command

hi, I would like to exlcude certain files which starts with AUS from a directory while gzip the files but i need it in gzip command only direct: AUS1.tx AUS2.txt NZ1.txt i want to gzip only NZ1.txt to NZ1.gz files starting with AUS should not be gzipped and i need it in gzip... (23 Replies)
Discussion started by: rohit_shinez
23 Replies

3. Shell Programming and Scripting

Exclude incomplete files in ls -rlt

Hi All, I am bit puzzled with this requirement where I need to list the files in a directory. However, files are being continuously written to this folder through FTP. Hence I need to exclude the file which is being written at the time of listing the directory. I thought of using file time... (5 Replies)
Discussion started by: angshuman
5 Replies

4. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

5. Shell Programming and Scripting

Using Grep Include/Exclude Files

I wrote this korn script and ran into a hole. I can use find to exclude all the hidden directories and to use my include file/exclude files for running a full backup find / -depth -ipath '/home/testuser/.*' -prune -o -print| grep -f include.mydirs | grep -v -f exclude.mydirs but when I... (8 Replies)
Discussion started by: metallica1973
8 Replies

6. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

7. Shell Programming and Scripting

Compression - Exclude huge files

I have a DB folder which sizes to 60GB approx. It has logs which size from 500MB - 1GB. I have an Installation which would update the DB. I need to backup this DB folder, just incase my Installation FAILS. But I do not need the logs in my backup. How do I exclude them during compression (tar)? ... (2 Replies)
Discussion started by: DevendraG
2 Replies

8. AIX

exclude files not working

HI, I have upgraded nim master and client to TL8,SP6. Now when the mksysb backup ran from master,it is not excluding directories specified in /etc/exclude.rootvg in the client.Instead,mksysb is getting created for all the file systems in the rootvg. This problem only appeared after the TL... (3 Replies)
Discussion started by: to_bsr
3 Replies

9. UNIX for Dummies Questions & Answers

list the files but exclude the files in subdirectories

If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also proj/code/test.sh proj/code/test1.c proj/code/unix... (8 Replies)
Discussion started by: shyjuezy
8 Replies

10. UNIX for Advanced & Expert Users

du (exclude files)

Hi, I want to get the disk usage of a directory. But I want it to ignore a particular directory within it. Lets say I want disk usage of all files/dirs within dir1 except those that are named .snapshot Does du have the option of excluding a particular directory. (1 Reply)
Discussion started by: the_learner
1 Replies
Login or Register to Ask a Question