shell command

Go down

shell command

Post  Admin on 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

View user profile http://computerclub09mnnit.forumotion.net

Back to top Go down

Re: shell command

Post  csbhagav on 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

View user profile

Back to top Go down

Re: shell command

Post  ankitgr8 on Sun Sep 07, 2008 9:02 am

ls ??
should work?
but its not working

ankitgr8

Posts : 6
Join date : 2008-08-11

View user profile

Back to top Go down

Re: shell command

Post  Gyanendra on Sun Sep 07, 2008 9:29 pm

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

Gyanendra

Posts : 8
Join date : 2008-09-07

View user profile

Back to top Go down

Re: shell command

Post  Admin on 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

View user profile http://computerclub09mnnit.forumotion.net

Back to top Go down

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