How to use 'ls' command to list files like *.dat, not *.*.dat?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use 'ls' command to list files like *.dat, not *.*.dat?
# 1  
Old 06-28-2017
How to use 'ls' command to list files like *.dat, not *.*.dat?

How to use 'ls' command to list files like *.dat, not *.*.dat
# 2  
Old 06-28-2017
Code:
ls | egrep '^[^\.]+\.dat'

Do I get a prize?

Seriously, I don't think either ls or any of the standard Linux shells will do what you want without doing something like the above. But I've been wrong before.

Andrew
This User Gave Thanks to apmcd47 For This Post:
# 3  
Old 06-28-2017
Thanks Andrew!

That's exactly what I was looking for...
# 4  
Old 06-28-2017
In bash try:
Code:
GLOBIGNORE=*.*.dat
ls *.dat

These 3 Users Gave Thanks to Scrutinizer For This Post:
# 5  
Old 06-28-2017
In (recent!) bash, try also
Code:
shopt -s extglob
ls !(*.*).dat

These 3 Users Gave Thanks to RudiC For This Post:
# 6  
Old 06-29-2017
I stand corrected! Smilie

Andrew
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed command to replace "|" with ^ for all *.dat files in a folder not working

I am trying to use the below sed command to replace all "|" to ^, in a folder had 50 dat files. when i tried with 1 file it worked but when i tried with wild card, is not working. sed -i 's/"|"/\^/g' *.dat Is this the proper way to use sed command thank you very much for help. (3 Replies)
Discussion started by: cplusplus1
3 Replies

2. Shell Programming and Scripting

Execute a Command in a .Dat File and use it in other Files

We have a process where we store the database password in a config file like below from where the password is picked up and used in Database Scripts ID, Password But we now have a Audit Requirement not to have the passwords in Config Files directly. We have a command which could fetch the... (2 Replies)
Discussion started by: infernalhell
2 Replies

3. Shell Programming and Scripting

Help with Getting distinct record count from a .dat file using UNIX command

Hi, I have a .dat file with contents like the below: Input file ============SEQ NO-1: COLUMN1========== 9835619 7152815 ============SEQ NO-2: COLUMN2 ========== 7615348 7015548 9373086 ============SEQ NO-3: COLUMN3=========== 9373086 Expected Output: (I just... (1 Reply)
Discussion started by: MS06
1 Replies

4. Shell Programming and Scripting

Help pls...Rename .dat files

Hi, I have some .dat files in some directories , i want them to be moved to another directory by changing file names. for ex: cat > /ai/rcmid/feb_files/temp/temp.txt aaa.dat bbb.dat rm -rf main rm -rf a001 rm -rf a002 mkdir main mkdir a001 mkdir a002 touch a001/aaa.dat touch... (1 Reply)
Discussion started by: Ravindra Swan
1 Replies

5. Shell Programming and Scripting

awk command on .DAT file not working?

Hi All, I am trying to run awk command on .DAT file and it is not working. The same command is working on .txt file: Contents of the file ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT: HEADER|ZZ_55555555_444444_ZZZZZZ_7777777_888_99.DAT... (10 Replies)
Discussion started by: sagar.cumar
10 Replies

6. OS X (Apple)

Script to process winmail.dat files in apple mail from outlook senders

Does anyone know of a way to automate the "massaging" of those STUPID winmail.dat files that come to Apple Mail extensions as a result from people sending mail from outlook clients? Specifically, something that would run when you attempt to open a winmail.dat file and auto extract and open... (2 Replies)
Discussion started by: herot
2 Replies

7. Red Hat

How to view all files on DAT tape

I'm using tar and so far so good, but how can I view ALL files without having to fast forward and rewind the tape? Let's say I append 100 files onto the tape. Having to fast forward 100 times until I find the file I want is kinda tedious. (3 Replies)
Discussion started by: sdotsen
3 Replies

8. UNIX for Dummies Questions & Answers

Using cp -r command to selectively omit *.dat files while copying a directory.

Hi all, I want to copy a directory named Ec1 to another directory named Ec2, newly created. But Ec1 has a bunch of *.dat files and many many other kinds of files. Whle creating Ec2, I selectively want to omit the *.dat files since they are huge files of the order of 100 MBs and there are... (5 Replies)
Discussion started by: d_sai_kumar
5 Replies

9. UNIX for Dummies Questions & Answers

Backup my files to DAT

hi guys, im using tru64 unix and i want to put my files on tapes. i have already a hp DAT storage, do you have any admin guides for backup/restore procedures for these? tnx (1 Reply)
Discussion started by: jefferson
1 Replies

10. Shell Programming and Scripting

compare two .dat files and if there is any difference pulled into a separate file

Hi, compare two .dat files and difference will be moved into separate file.if anybody having code for this please send asap. using diff command, i don't know how to write shell programming. and my first file is like this including Header and trailer 10Ç20060323Ç01(Header) 01ÇIÇbabuÇ3000 01ÇIÇbaluÇ4000... (1 Reply)
Discussion started by: kirankumar
1 Replies
Login or Register to Ask a Question