ls ignore pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls ignore pattern
# 1  
Old 03-22-2010
ls ignore pattern

Hi,

I have a FTP script that check for ".done" files in the remote path and the "get" the corresponding data files. Here's how it does.....

First it list all the *.done file as below:

Code:
 
ls *.done

And then it picks one file and get the corresponding data file. After that it renames that ".done" file to ".done.done" Now the problem is that the next time when I list the ".done" file it should somehow ignore ".done.done" files. Here's something I found in this forum: https://www.unix.com/shell-programmin...ls-ignore.html

But the problem of using this is:

Code:
ls -l -I '*.done.done'

command 1

that it would also list data files which would not have ".done" files. I even tried:

Code:
ls *.done | grep -v done.done

command 2

this works fine when I do that on the local m/c path. But not sure if I can do that in the remote path. I tried and it throws error:

Code:
Couldn't stat remote file: No such file or directory
Can't ls: "/home/<dir>/" not found

in both the commands. Please suggest.

-dips
# 2  
Old 03-23-2010
The obvious answer - name it something.done.finished or whatever.
If your written requirements state that 'done.done' must be the final result,
then name everything *.done.finished and at the end rename *.done.finished to *.done.done

However the next time your code runs you will still have the done.done problem.
The only work around for that is to connect, get a full file listing into a local file, disconnect, then parse out the files you want, reconnect and process the files in your list. Which is a lot of work compared to *.done.finished.

The other thing to note is that ls under ftp and sftp does not support all of the options you may have on the local box.
# 3  
Old 03-23-2010
# 4  
Old 03-25-2010
Hi,

Yes jim mcnamara even I proposed the obvious; and now the design team has agreed to rename the remote .done files to .finished.

Also as this ftp script needs to be called from 28 different processes in parallel (at the exact moment) creating the full list in the local m/c and then parsing it was a tedious job. So smart thing was to change the extension :-)

Thanks to you both for your time.

-dips
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

3. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

4. Shell Programming and Scripting

Ignore case in awk while pattern searching

Hi , I have the file where i have to search for the pattern. The pattern may be lower case or upper case or camel case. Basically I want to ignore while searching the pattern in awk. awk '/error|warning/exception/' filename Please help me (3 Replies)
Discussion started by: arukuku
3 Replies

5. Shell Programming and Scripting

Help needed for diff to ignore a line with certain pattern

Hello Guys, I request anyone to do me a small help in using diff command for following. I am trying to compare two files for content and wish to keep the content after the comparison (The resultant file can't be blank) However, the first lines would be different in both files and I need diff... (2 Replies)
Discussion started by: rockf1bull
2 Replies

6. Shell Programming and Scripting

How to ignore first or last parameter

Can someone help me of doing something like this send.sh #!/bin/bash for last; do true; done echo $* | gammu sendsms TEXT $last every thing is good except that when i launch the script like this ./send.sh This is the message i want to send +63922XXXXXXX it turned out the message of... (2 Replies)
Discussion started by: arturo322
2 Replies

7. Shell Programming and Scripting

how to ignore case

Hi All, The means I use to ignore case, as an example is the following snippet: It should accept any oof the following y|Y|YES|Yes|n|N|NO|No echo "Enter Y/N to continue: " read choice; (3 Replies)
Discussion started by: raghur77
3 Replies

8. UNIX for Dummies Questions & Answers

Ignore a string pattern while doing file comparison/difference

Here is my problem. I have to find the differences in 2 XML files This is my Old File contents - File1 <FILEHDR> <Bag xsi:nil='true'></Bag> </FILEHDR> This is my New File contents - File2 <FILEHDR> <Bag xsi:nil='true' ></Bag> </FILEHDR> When I do the following diff -b File1 File2... (1 Reply)
Discussion started by: sksahu
1 Replies

9. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

10. UNIX for Dummies Questions & Answers

please ignore this....

Most of the people think that they can not use Unix as desktop. By this poll we gone tell them that we not just use Unix as desktop but also love different display managers like GNOME, KDE etc..... (1 Reply)
Discussion started by: ynilesh
1 Replies
Login or Register to Ask a Question