shell command

View previous topic View next topic Go down

shell command

Post  Admin on Sun Aug 17, 2008 5:32 pm

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 1:53 pm

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 3:02 pm

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 Mon Sep 08, 2008 3:29 am

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 9: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

View previous topic View next topic Back to top


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