To identify filename in which having match PATTERN


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To identify filename in which having match PATTERN
# 8  
Old 03-23-2008
Quote:
Originally Posted by era
*bling* Useless Use of Glob in Backticks! Also the "ls -l" actually is a rather grave error. You could simply drop the -l, but the whole ls is redundant.
if you would read it right... it's no an -l it's -1... so this should work!
# 9  
Old 03-23-2008
Oops. my bad, sorry. It's still Useless because ls doesn't actually add anything, the glob is expanded by the shell before ls sees it, and ls -1 (one) will still be wrong if there are subdirectories.
# 10  
Old 03-23-2008
jepp... so it was a point to start of for the original poster... i'm not going to write a script (even a small one) for other people. they should do the work and if they come to a point where they don't get any further, they can ask.
if you are in a direchtory and do an "ls -1 *.gz" you get every file with .gz at the end in THAT directory... so what is the problem?
if your solution works... fine. but the above works also! but let the original poster work out the solution that works for HIM.

greets,
DN2
# 11  
Old 03-23-2008
Quote:
Originally Posted by DukeNuke2
if you are in a direchtory and do an "ls -1 *.gz" you get every file with .gz at the end in THAT directory... so what is the problem?
If there are directories matching the wildcard, that is not what you will get. It's a fairly academic point in this particular context, but why not give hints which are correct regardless of circumstances.

At the risk of hubris, I suggest you google for "useless use of backticks".
# 12  
Old 03-23-2008
Quote:
Originally Posted by era
If there are directories matching the wildcard, that is not what you will get. It's a fairly academic point in this particular context, but why not give hints which are correct regardless of circumstances.
i think my hint wasn't uncorrect... maybe your way ist better/nicer/other... whatever. my solution works and yours works also and is better code. Smilie
but which directory matches the wildcard *.gz?

Quote:
Originally Posted by era
At the risk of hubris, I suggest you google for "useless use of backticks".
nice one. added it to my bookmarks.
# 13  
Old 03-23-2008
Quote:
Originally Posted by DukeNuke2
but which directory matches the wildcard *.gz?
It depends.

Code:
mkdir "i can name my directories whatever I like (*:".gz

# 14  
Old 03-23-2008
Quote:
Originally Posted by era
It depends.

Code:
mkdir "i can name my directories whatever I like (*:".gz

jepp... i see something like that all the time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Regex to identify pattern

Hi In a file I have string in multiple lines. Like below: <?=test.getObjectName("L", "testTBL","D") ?> <?=test.getObjectName("L", "testTBL","testDB", "D") ?> I want to use regex to search for the pattern "<?=test.getObjectName...?>" If the parenthesis has 3 parameters then return 2nd... (5 Replies)
Discussion started by: dashing201
5 Replies

2. Shell Programming and Scripting

Match filename pattern with -f

Hello All, I have two issues. 1).I want to check if directory exists and inside that if file exists with today's date minus one. I can check directory exists but how can i check only a pattern of filename in that directory.Name of file is files-20170105-09.gz. 2).Also i want to exit immediately... (6 Replies)
Discussion started by: looney
6 Replies

3. Shell Programming and Scripting

Identify file pattern, take count of pattern, then act

Guys - Need your ideas on a section of code to finish something up. To make a long story short, I'm parsing a print output file that goes to pre-printed forms. I'm intercepting it, parsing it, formatting it, cutting it up into individual pages, grabbing the text I want in zones, building an... (3 Replies)
Discussion started by: ampsys
3 Replies

4. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

5. 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

6. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

7. Shell Programming and Scripting

Getting filename for Nth line pattern match

Hi, I have many scripts in particular directory. And few of the scripts have exit 0 in second line. Now i wanted to list out the scripts name which has the exit 0 in its second line I tried many options , but i can not get the filename along with the nth line pattern match :mad:. Can anyone... (14 Replies)
Discussion started by: puni
14 Replies

8. Shell Programming and Scripting

Filename pattern match and appending pipe

Hi, I have a directory with around 100k files and files with varying sizes(10GB files to as low as 5KB). All the files are having pipe dilimited records. I need to append 7 pipes to the end of each record, in each file whose name contains _X3_ and need to append 10 pipes to the end of each... (3 Replies)
Discussion started by: nss280
3 Replies

9. Shell Programming and Scripting

Match first pattern first then extract second pattern match

My input file: <accession>Q91G55</accession> <name>043L_IIV6</name> <protein> <recommendedName> <location> <position position="294"/> </location> <fullName>Uncharacterized protein 043L</fullName> <accession>P18556</accession> <name>1106L_ASFB7</name> <protein> <recommendedName>... (5 Replies)
Discussion started by: patrick87
5 Replies

10. Shell Programming and Scripting

Does Filename Match Pattern

Hi, I am writing a BASH script. I have a list of files and I would like to make sure that each is of a specific pattern (ie *.L2). If not I would like to remove that file. How do I test whether a filename matches a given pattern? Thanks a lot. Mike (10 Replies)
Discussion started by: msb65
10 Replies
Login or Register to Ask a Question