Searching range of filenames witn and without numbers on the end


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching range of filenames witn and without numbers on the end
# 1  
Old 08-15-2014
Searching range of filenames witn and without numbers on the end

So I'm grepping for the following right now:

Code:
ls -la /somedirectory/*.log* | awk '{print $9}'

The problem with this is that I get the following output:

Code:
/somedirectory/errors_1_foo.log
/somedirectory/errors_1_foo.log.1
/somedirectory/errors_1_foo.log.2
/somedirectory/errors_1_foo.log.3
/somedirectory/errors_1_foo.log.4
/somedirectory/errors_1_foo.log.5

The problem is that I only need the following logfiles to show up in the search.

Code:
/somedirectory/errors_1_foo.log
/somedirectory/errors_1_foo.log.1

How would I modify my command above to only get these files?

Thanks in advance!
# 2  
Old 08-15-2014
Try:-
Code:
ls -1 /somedirectory/*.log /somedirectory/*.log.[0-1]

You don't say that you want to do anything else with these files, so there is no context for us to suggest anything else at the moment.

It might seem a flippant answer, but you've not really asked much.



Note that the flag is a numeric one rather than a lower case L.




Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 08-15-2014
Thank you. This is exactly what I need. I haven't had much sleep lately, so I hit a simple wall on this one.
# 4  
Old 08-15-2014
Join the club. Which four letter word is it - kids or work?


Robin
# 5  
Old 08-19-2014
Both, and a three-letter word called "car." I had to do maintenance which involved removing the turbo, replacing some studs,and putting it all back.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching same filenames in different partitions

Hi, We are doing some migration work. The same files may exist in different partition/mountpoints. We may place it in a single place, hence we don't want any duplicates...we will rename the file names if we know the files which has duplicates(by file name)). It would be nice if a script... (3 Replies)
Discussion started by: saravanapandi
3 Replies

2. UNIX for Dummies Questions & Answers

Searching for a pattern from filenames stored in a file

Hi, I have got some 10 filenames stored in a file or displayed in the console as a result of some query i made.. Now I need to open each of these files and search for a pattern in these 10 files.. Can someone help me with this? Thanks, Jean (9 Replies)
Discussion started by: jeanjkj
9 Replies

3. UNIX for Dummies Questions & Answers

Need help in searching a file by range

hi, i need to search a file by range, the file (f3.txt) contains: x1=0123318739 x2=0120123456 x3=0120453576 x4=0110445654 x5=0120432343 x6=0129423 x7=0104323433 x8=01232132134 x9=0122344242 x10=012006196 x11=012016546 x12=012091235 x13=0121064598 x14=012194562 x15=0122028556... (3 Replies)
Discussion started by: takyeldin
3 Replies

4. UNIX for Dummies Questions & Answers

Searching by date range from filenames

Hello all, i have tons of files in folder named like this (yyyymmdd): bookcollection20100729 bookcollection20100730 bookcollection20100731 bookcollection20100801 bookcollection20100802 etc. I need to find files with date range in there names lets say from 2010.07.30 - 2010.08.02 ... (10 Replies)
Discussion started by: Whit3H0rse
10 Replies

5. Shell Programming and Scripting

Searching the lines within a range of time period in a text file

Dear All, Please advice me, I have a text file with one field date and time like below given. I need to find out the lines whchi content the time stamp between Wed May 26 11:03:11 2010 and Wed May 26 11:03:52 2010 both can be included, using awk command which could be an interactive so that I... (6 Replies)
Discussion started by: chinmayadalai
6 Replies

6. UNIX for Dummies Questions & Answers

Searching for specific filenames

Hi I would like to know how to search through a directory and pull out files that has a specific pattern in the filename. For example if the filename has "bsc" in it, then that file must be moved to another directory where I will perform some operations on it. I know grep can be used, but I'm... (17 Replies)
Discussion started by: ladyAnne
17 Replies

7. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

8. Shell Programming and Scripting

Filenames created with '\r' characters at the end

Hi all, Am creating files and doing copy,compare and deletion. As i do not want to mention the filepath everywhere, i store the filepaths in variables. FILENAME="/home/test/create/Myfile.txt" WR_PATH="/home/test/wrie/writefile.txt" RD_PATH="/home/test/myread/readfile.txt" echo "This is my... (2 Replies)
Discussion started by: amio
2 Replies

9. UNIX for Advanced & Expert Users

Searching filenames containing certain text???

Suppose there are multiple files containing certain text "abc". How to print the name of all such files with a single command from unix prompt? Thanks in advance (6 Replies)
Discussion started by: skyineyes
6 Replies

10. Shell Programming and Scripting

searching for filenames with search strings in another file

Hi, I have 5 files in a directory. emp1_usage.txt emp2_usage.txt emp3_usage.txt emp4_usage.txt emp5_usage.txt I am using sqlldr to get the contents of the above 5 files and store it in a temp table and update my original table using temp table. for f in *emp*.txt do sqlldr... (3 Replies)
Discussion started by: pathanjalireddy
3 Replies
Login or Register to Ask a Question