Listing files with an certain extension


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing files with an certain extension
# 1  
Old 02-09-2016
Listing files with an certain extension

I'm suppose to write a command that would list all files that end in .tx with an optional t at the end.

So far all I got is listing the files that end in .tx which is:

Code:
ls *.tx

Now my problem is how do I add the optional t at the end.
# 2  
Old 02-10-2016
Try:
Code:
ls *.tx *.txt

# 3  
Old 02-10-2016
Try:
[CODE]ls *.tx[t][/CODE]
EDIT:
Oops, was too certain it would work.

Try this instead:
Code:
ls *.{tx,txt}

hth

Last edited by sea; 02-10-2016 at 11:12 AM..
# 4  
Old 02-10-2016
Note: brace expansion ({foo,bar}) is supported by bash/ksh93/zsh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

2. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

3. Shell Programming and Scripting

Python - glob () - How to grep same files with different extension files

Hi I Have a directory and i have some files below abc.txt abc.gif gtee.txt ghod.pid umni.log unmi.tar How can use glob function to grep abc files , i have created a variable "text" and i assigned value as "abc", please suggest me how can we use glob.glob( ) to get the output as below... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

4. UNIX for Dummies Questions & Answers

How to list files with no extension together with *.prog files?

Hi, I know that to list files with no extension, we can use.. ls -1 | grep -v "\." And to list .prog files, we can use.. ls -1 *.prog or ls -1 | grep '.prog$' (4 Replies)
Discussion started by: adshocker
4 Replies

5. Shell Programming and Scripting

Listing the files of .cv and .config extension

hi all, I have a directory which can contain multiple sub - directories. My input would be the directory name. Script should search in all the directories for the files having .cv and .config extension. Till now am able to get the files of only one type os extension. FILES=.... (3 Replies)
Discussion started by: flamingo_l
3 Replies

6. Shell Programming and Scripting

Listing the files

Hi, I have to list the files in a particular folder which are having file names like below: 1000_aa.csv, 1000_ab.csv, 1000_az.csv,1000_ba.csv,1000_bb.csv,1000_ca.csv,1000_cb.csv. How can i get the list? Thanks, Selva (2 Replies)
Discussion started by: bharathappriyan
2 Replies

7. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

8. HP-UX

Files without extension

I am brand new to hp unix systems. I see some files without extension on this system. If I type name of the file it shows me so many detail but does not take me back to command prompt. What are these files and how do I come back to command prompt? Please help (1 Reply)
Discussion started by: rajahindustani
1 Replies

9. UNIX for Advanced & Expert Users

listing files excluding files from control file

I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file. Sample control file: TEST SEND SFFFILE CONTL The directory contains followign... (15 Replies)
Discussion started by: ukatru
15 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question