Redirect output as argument for other command(plz help)

View previous topic View next topic Go down

Redirect output as argument for other command(plz help)

Post  goldberg on Tue Sep 16, 2008 10:52 am

How do we redirect output of one command as argument to another command
Actually i m searching for answer of question of tux wars
:
Suppose the root user wants to go into the home directory of user named "cs054011" what command will he execute at his shell. Assume he doesn't know the exact pathname of directory.
Now if I use the command
find . -name "cs054011" -print I will get the path of the user but how to redirect it as argument to cd

goldberg

Posts: 8
Join date: 2008-08-11

View user profile

Back to top Go down

Re: Redirect output as argument for other command(plz help)

Post  Admin on Tue Sep 16, 2008 11:45 am

you can use pipe to redirect input and output of one command to use each other ...........
ls|wc -l
in this command output of ls is taken as input og wc -l
just go through pipes for mor edetails...........
Very Happy

Admin
Admin

Posts: 39
Join date: 2008-08-03

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

Back to top Go down

Re: Redirect output as argument for other command(plz help)

Post  goldberg on Tue Sep 16, 2008 6:49 pm

I don't want it to be input for the other command but as an argument for it.
find . -name "cs054011" -print [something] cd
This something should be such that the output of find . -name "cs054011" -print should be argument for cd

goldberg

Posts: 8
Join date: 2008-08-11

View user profile

Back to top Go down

Re: Redirect output as argument for other command(plz help)

Post  ankurgutpa on Wed Sep 17, 2008 10:53 pm

for ur question of TUX war just type the following command line sequence
Code:

$ su - cs054011
$ pwd
$ exit

after executing pwd root will get the absolute path for home directory of user cs054011 and then after exiting from his enviournment root can go to his home directory as a root itself cheers

ankurgutpa

Posts: 44
Join date: 2008-08-10
Age: 22
Location: Tandon 72

View user profile

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