Change to directory and search some file in that directory in single command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Change to directory and search some file in that directory in single command

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-21-2013
saurau saurau is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 20 June 2014, 4:03 AM EDT
Posts: 23
Thanks: 4
Thanked 0 Times in 0 Posts
Change to directory and search some file in that directory in single command

I am trying to do the following task :


Code:
export ENV=aaa
export ENV_PATH=$(cd /apps | ls | grep $ENV)

However, it's not working. What's the way to change to directory and search some file in that directory in single command

Please help.

Last edited by Scrutinizer; 01-21-2013 at 07:10 AM.. Reason: code tags
Sponsored Links
    #2  
Old 01-21-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 30 September 2014, 3:21 PM EDT
Location: Amsterdam
Posts: 9,487
Thanks: 280
Thanked 2,398 Times in 2,150 Posts
Try replacing the first pipe by a semicolon.
Sponsored Links
    #3  
Old 01-21-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 29 September 2014, 1:02 PM EDT
Location: Simplicity
Posts: 1,924
Thanks: 123
Thanked 561 Times in 509 Posts
... or better replace it by && (two ampersand = logical "and"; only continue with the "ls | grep ..." if the "cd ..." was succesful).
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Single command to delete a directory jorogon0099 Homework & Coursework Questions 5 10-13-2009 06:10 PM
CD (change directory) - Not advisable for executing a command samplify Shell Programming and Scripting 2 05-27-2009 10:13 AM
Change directory command (cd) c00kie88 Shell Programming and Scripting 21 07-11-2008 10:01 AM
search in a directory using grep command malaymaru Shell Programming and Scripting 4 05-23-2005 09:45 AM
Change directory command (cd) oscarr Shell Programming and Scripting 4 08-23-2002 08:30 AM



All times are GMT -4. The time now is 11:58 PM.