Fiding file except file name written in another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fiding file except file name written in another file
# 1  
Old 08-17-2012
Fiding file except file name written in another file

HI All,

Actually i have file xxx.txt where entry is like as follow.
prepaid_123.txt
prepaid_134.txt
prepaid_156.txt

So my problem is i want to find all fille except these three file in current directly of same format prepaid_xxx.txt

Can you please help

Thanks in Adcance
# 2  
Old 08-17-2012
Perhaps the file is not needed, but regex in find will suffice..
Code:
find . -type f ! -name "prepaid_[0-9][0-9][0-9].txt"

# 3  
Old 08-17-2012
Like this?
Code:
eval "ls @(!("$(paste -sd'|' xxx.txt)")&prepaid_???.txt)"


Last edited by elixir_sinari; 08-17-2012 at 06:15 AM..
# 4  
Old 08-17-2012
Quote:
Originally Posted by elixir_sinari
Getting Error OutPut is as follow
Code:
@(!(prepaid_123.txt|prepaid_134.txt|prepaid_156.txt)&prepaid_???.txt) not found

---------- Post updated at 06:06 AM ---------- Previous update was at 06:03 AM ----------

Quote:
Originally Posted by Peasant
Below command not able to fine prepaid_135.txt which is not mentioned in xxx.txt. Because format is same
prepaid_[0-9][0-9][0-9].
Code:
find . -type f ! -name "prepaid_[0-9][0-9][0-9].txt"

---------- Post updated at 06:07 AM ---------- Previous update was at 06:06 AM ----------

Quote:
Originally Posted by sujit_kashyap
HI All,

Actually i have file xxx.txt where entry is like as follow.
prepaid_123.txt
prepaid_134.txt
prepaid_156.txt

So my problem is i want to find all fille except these three file in current directly of same format prepaid_xxx.txt

Can you please help
Small addition i want to delete other file as well which is not written in file

Thanks in Advance
# 5  
Old 08-17-2012
That means that there are no files in the current directory whose names:
1) are not in the xxx.txt file, and
2) are not matching the pattern prepaid_???.txt

Check the directory contents...
# 6  
Old 08-17-2012
Code:
ls prepaid_[0-9][0-9][0-9].txt | grep -v -f xxx.txt

This User Gave Thanks to raj_saini20 For This Post:
# 7  
Old 08-17-2012
Quote:
Originally Posted by elixir_sinari
Like this?
Code:
eval "ls @(!("$(paste -sd'|' xxx.txt)")&prepaid_???.txt)"

Please enlighten me - explain that construct for ls!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check if a file is open and in use (logs are being written to it)

Hello Experts, I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this. while true; do echo `date` >>abc.txt; done then I checked lsof |... (5 Replies)
Discussion started by: shekhar_4_u
5 Replies

2. Programming

How to prevent a C++ program reading a file that is still being written to.?

Hi, Hopefully someone can help. We have a process that writes a file using Connect Direct to our local Solaris server and then our C++ program will pick up the file and process it. Unfortunately, because of the size of the file, the C++ program is processing the file before it has finished... (7 Replies)
Discussion started by: chris01010
7 Replies

3. Shell Programming and Scripting

Notification as popups when a file being written

I would like to know Is it possible to get a notification as pop-up in linux when a folder with extension '.aqs' written a popup should come as " The folder has been written " Thank you in advance (5 Replies)
Discussion started by: bal_nair
5 Replies

4. UNIX for Advanced & Expert Users

How to copy a binary file while the file is being written to by another process

Hello, Can I copy a binary file while the file is being written to by another process? Another process (program) “P1” creates and opens (for writing) binary file “ABC” on local disk. Process P1 continuously write into ABC file every couple of seconds, adding 512-byte blocks of data. ABC file... (1 Reply)
Discussion started by: mbuki
1 Replies

5. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

6. UNIX for Dummies Questions & Answers

Appending something to output before being written to a file

Hi, I'm quite stuck with what I thought should've been simple but I just can't seem to do it. Firstly, I have the following done in bourne shell: cat datafile | tr '' '' >> newfile echo "$fullfilepath" >> newfile i want to have the output of that echo put on the same line as the output... (4 Replies)
Discussion started by: Darkst
4 Replies

7. UNIX for Dummies Questions & Answers

How the /etc/passwd file is written when user does not have permission

Hi, /etc/passwd file has write permission only for the root user. Now when a normal user changes the its own password using passwd command, how this information has been written to the /etc/passwd file when the user is not having write permission to this file. ~santosh (2 Replies)
Discussion started by: santosh149
2 Replies

8. Shell Programming and Scripting

Checking a file is not being written to

Hello All I am attempting to write a shell script (bourne shell script) which will copy a tar'd and compressed file from a directory to a staging area but will not know whether the file is still open for write since files are being ftp's to my site at random times during the day. Once I am... (14 Replies)
Discussion started by: kanejm
14 Replies

9. UNIX for Dummies Questions & Answers

Operating on a file being written by another application

Hi, I have a directory that is used to store files generated by another application. Each file is huge and can take some time to produce. I am writing a shell script to check the names and dates of the files and do some functions on the ones that are not being written out. My question is, if I... (3 Replies)
Discussion started by: GMMike
3 Replies

10. UNIX for Dummies Questions & Answers

File being used/written

Hello, Which command in unix can tell whether a file is being used/written by another process. e.g. If one process is copying a very big file in some directory and there is another cronjob process which checks for a new file and in this directory and process the file. I want to check, if the... (4 Replies)
Discussion started by: sanjay92
4 Replies
Login or Register to Ask a Question