show a list of files whose names begin


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers show a list of files whose names begin
# 1  
Old 02-24-2009
show a list of files whose names begin

How do I show a list of files whose names begin with c and are two characters long.
ls [^c] {2\}

? thanks

Last edited by vgersh99; 02-24-2009 at 06:51 PM..
# 2  
Old 02-24-2009
I'm sure there's a better way, but here's what comes right to mind. Using ls -al:

Code:
ls -al | awk 'length($9)==2 && $9 ~ "^c"'

On my system, the 9th field is the filename... you might have to change that. Using just ls:

Code:
ls | awk 'length==2 && $0 ~ "^c"'

# 3  
Old 02-24-2009
Code:
ls c?

# 4  
Old 02-24-2009
Quote:
Originally Posted by vgersh99
Code:
ls c?

Heh, yep, there's the much simpler way. I never give ? enough credit... But why use 5 characters when 36 will suffice? :-)
# 5  
Old 02-24-2009
grep “[12]*"

Cool Thanks!
What about:
Write the grep command to find the lines in
cat stu
Jim Miller Mktg 12 A
students who are in 12th grade
grep “[12]* ” stu

?
# 6  
Old 02-24-2009
homework, eh?
Posting homework is against the rules.
# 7  
Old 02-24-2009
Is this a homework assignment?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to list files names and sizes in a directory and output result to the file?

Hi , I'm trying to list the files and output is written to a file. But when I execute the command , the output file is being listed. How to exclude it ? /tmp file1.txt file2.txt ls -ltr |grep -v '-' | awk print {$9, $5} > output.txt cat output.txt file1.txt file2.txt output.txt (8 Replies)
Discussion started by: etldeveloper
8 Replies

2. Shell Programming and Scripting

Finding a string in a list of files, print file names

I'm interested in writing a report script using BASH that searches all of the files in a particular directory for a keyword and printing a list of files containing this string... In fact this reporting script would have searches for multiple keywords, so I'm interested in making multiple... (2 Replies)
Discussion started by: chemscripter904
2 Replies

3. Shell Programming and Scripting

While loop a file containing list of file names until the files are found?

Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Discussion started by: laknar
5 Replies

4. UNIX for Dummies Questions & Answers

How to list the names of the files from all the subdirectories?

Hi, I'm currently trying to print the names of all the .txt files in the subdirectories that contain the string I'm searching. I tried with this code, but it seems that it searches for the names that matches the string instead of searching for the string in the individual files and printing the... (2 Replies)
Discussion started by: nuclearpenguin
2 Replies

5. Shell Programming and Scripting

Copying List of Files Under Different File Names ?!

Hi to all here , Excuse me for the lamer question but I need UNIX command for copying List of Files Under Different File Names ! for example I have this list: new_001.jpg new_002.jpg new_003.jpg ..... I want to copy all files that start with "new_" to the same directory but under... (7 Replies)
Discussion started by: boboweb_
7 Replies

6. Shell Programming and Scripting

Compare list [ names and size files ]

Hello, I've downloaded a huge amont of files I've got a list of files from a remote server. -rw-r--r-- 1 str661 strem 453465260 Dec 16 15:54 SATRYS2V1_20021218_temp_bias.nc -rw-r--r-- 1 str661 strem 17669468 Dec 16 18:01 SATRYS2V1_20021225_hdyn_bias.nc -rw-r--r-- 1... (9 Replies)
Discussion started by: Aswex
9 Replies

7. Shell Programming and Scripting

how to copy files followed by list of names of all the files in /etc?

....... (2 Replies)
Discussion started by: pcbuilder
2 Replies

8. UNIX for Dummies Questions & Answers

How can i copy a list of files with different names into others directory have the same name?

dear all. how can i copy a list of files with different names into others directory have the same name like i have 3 files 10_10 10_10_11 10_10_11_12 and i have 3 directories 10_10 10_10_11 10_10_11_12 how can i make a loop to cp this files into the directory have the same name like... (31 Replies)
Discussion started by: t17
31 Replies

9. Shell Programming and Scripting

how can i copy a list of files with different names into others directory have the same name

dear all. how can i copy a list of files with different names into others directory have the same name like i have 3 files 10_10 10_10_11 10_10_11_12 and i have 3 directories 10_10 10_10_11 10_10_11_12 how can i make a loop to cp this files into the directory have the same name like... (0 Replies)
Discussion started by: t17
0 Replies

10. Shell Programming and Scripting

Show column names when access a table using perl

Hi all, I am using the following code in order to access the data of a table: my $sql = qq{ SELECT * FROM cc_test_cases}; $sth = $dbh->prepare( $sql ); $sth->execute( ); while(@row1 = $sth->fetchrow_array()) { # print "$row1: $row1\n"; print "@row1\n"; #print("THE VALUE... (1 Reply)
Discussion started by: chriss_58
1 Replies
Login or Register to Ask a Question