Linux file listing options for DOS users

December 1, 2010 at 04:31:06
Specs: linux
In Dos, I can easily list all the files that has letter a as second character in the filename using this command: dir ?a*.txt /s (the /s option allow me to include sub-folders)

How do I do the same with linux ls command?

See More: Linux file listing options for DOS users

December 1, 2010 at 13:18:40
Two things. One is to get a similar linux command. If you want to use ls then the way to get more information about it is to use what is called man pages.

Command is man ls or man cp or man chdir or such.

In linux one can also put commands in an order to perform complex tasks on a single line.

Try the man pages first for a way to get what you need. If no solution we'll try to create a command that should work.

Why did it take me over a year to phone in a problem to ATT?

Report •

December 1, 2010 at 17:29:00
I have read the man pages but unable to find the correct option combination to give the same result. I end up combining with grep command which is troublesome as I need to type so much more characters to do the same thing. So I wonder does any Linux experts here know any more effective ways to do this commonly used command, else it will be really troublesome to type so much so often. :(

btw, I have also tried the find command, it works but execute far slower. :(

Report •

December 1, 2010 at 18:46:27
Sorry. I forget sometimes.

You might look at the find command also.

See this page too.

Why did it take me over a year to phone in a problem to ATT?

Report •

Related Solutions

December 1, 2010 at 19:37:53
How are you using the find command? find is normally efficient. This is the way I am using it:

find . -type f -name "?a*.txt" -print

Report •

December 4, 2010 at 09:39:02
The command to list all txt files with a as second character and show total number of these files and the total storage these files used in Windows:

dir ?a*.txt /s

To do the same in Linux with my limited knowledge (I can't find a way to add up the amount of storage these listed file used):
find -iname '?a*.txt' -ls
find -iname '?a*.txt' | wc -l

Is there really no faster way to do a file listing on a linux with total number of files and storage used by these files vs Windows?

Report •

December 11, 2010 at 00:10:18
I found out how to do this including storage used:

dir ?a*.txt /s

find -iname '?a*.txt' | du -bh; find -iname '?a*.txt' | wc -l

Report •

December 12, 2010 at 13:59:53
Am I missing something? What's wrong with

ls -R ?a*.txt

Report •

December 12, 2010 at 14:10:04
ls doesn't give you a total of the listed file numbers (wc required) and storage used (du required) like DOS dir will.

Report •

December 13, 2010 at 00:01:55
So write a script to do it for you, and name it "dir". You can even support switches so it works like the DOS command (just a thought) . . .

Ernie Registered Linux User 247790

Report •

December 13, 2010 at 01:34:57
Agreed. Can make use of alias to duplicate DOS/Windows commands to make Linux more user-friendly to encourage Windows users to switch over.

Just like Redhat has an alias for executing ls -l with ll. It's more productive if Linux could make these as default in all Linux distributions.

Report •

Ask Question