Computer Club MNNIT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

shell command

4 posters

Go down

shell command Empty shell command

Post  Admin Sun Aug 17, 2008 11:32 am

Just write a single shell command without any pipes to list all those files
in the current directory whose filenames are just two characters long.?
Question

Admin
Admin

Posts : 39
Join date : 2008-08-03

https://computerclub09mnnit.forumotion.net

Back to top Go down

shell command Empty Re: shell command

Post  csbhagav Tue Aug 19, 2008 7:53 am

is this a doubt or jus for knowledge sharing purpose ???

csbhagav

Posts : 3
Join date : 2008-08-18

Back to top Go down

shell command Empty Re: shell command

Post  ankitgr8 Sun Sep 07, 2008 9:02 am

ls ??
should work?
but its not working

ankitgr8

Posts : 6
Join date : 2008-08-11

Back to top Go down

shell command Empty Re: shell command

Post  Gyanendra Sun Sep 07, 2008 9:29 pm

find . -name ?? -print
wud this work !!

Gyanendra

Posts : 8
Join date : 2008-09-07

Back to top Go down

shell command Empty Re: shell command

Post  Admin Thu Sep 11, 2008 3:00 am

the find command is wrong. You need to use "-maxdepth 1" to limit the search to the current directory.
If you only want to look at files, then use "-type f". You main mistake is that the ?? should be inside double quotes.
You want:
find ./ -maxdepth 1 -type f -name "??"

If you have 3 files; aa, bb and cc in the current directory and try to run
find ./ -name ??
You are really entering the command:
find ./ -name aa bb cc
because of file globbing by the shell.
ls ?? will also not work
there is also a very simple command that will do the job ? Very Happy

Admin
Admin

Posts : 39
Join date : 2008-08-03

https://computerclub09mnnit.forumotion.net

Back to top Go down

shell command Empty Re: shell command

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum