Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

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

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-21-2013
saurau saurau is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 23 February 2016, 5:57 AM EST
Posts: 27
Thanks: 6
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 08:10 AM.. Reason: code tags
Sponsored Links
    #2  
Old Unix and Linux 01-21-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 4 December 2016, 11:03 AM EST
Location: Amsterdam
Posts: 11,101
Thanks: 440
Thanked 3,108 Times in 2,749 Posts
Try replacing the first pipe by a semicolon.
Sponsored Links
    #3  
Old Unix and Linux 01-21-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 4 December 2016, 10:30 AM EST
Location: Simplicity
Posts: 3,312
Thanks: 253
Thanked 1,076 Times in 975 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 Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 07:10 PM
CD (change directory) - Not advisable for executing a command samplify Shell Programming and Scripting 2 05-27-2009 11:13 AM
Change directory command (cd) c00kie88 Shell Programming and Scripting 21 07-11-2008 11:01 AM
search in a directory using grep command malaymaru Shell Programming and Scripting 4 05-23-2005 10:45 AM
Change directory command (cd) oscarr Shell Programming and Scripting 4 08-23-2002 09:30 AM



All times are GMT -4. The time now is 12:15 PM.