two commands on 1 line | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

two commands on 1 line

UNIX for Advanced & Expert Users


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-20-2003
el_soldado el_soldado is offline
Registered User
 
Join Date: Nov 2003
Last Activity: 2 December 2003, 12:03 PM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
two commands on 1 line

wuts the command that allows u to use 2 commands on one line?
Sponsored Links
    #2  
Old 11-20-2003
google's Avatar
google google is offline Forum Advisor  
Advisor
 
Join Date: Jul 2002
Last Activity: 17 June 2009, 5:17 PM EDT
Location: Atlanta
Posts: 740
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
wuts the command that allows u to use 2 commands on one line?
if you dont mind, english please! Read the rules of the board.

you can run multiple commands on a single line by separating the commands by a semi colon.

example:

echo $PWD ; ls -a

You can also run multiple commands on a single line via a pipe. The pipe takes the output of one command and "pipes" it as input to another command.

example:

ps -ef | grep ORA
Sponsored Links
    #3  
Old 11-20-2003
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
 
Join Date: Nov 2003
Last Activity: 21 January 2014, 4:03 PM EST
Location: Belize
Posts: 484
Thanks: 0
Thanked 3 Times in 2 Posts
Also, if you want to conditionally execute the second command based on the return code of the first you can use || or &&.

<command1> && <command2> will execute command2 if command1 returns a value >= 0 (ie success).

<command1> && <command2> will exeucte command2 if command1 returns a value < 0 (ie failure)

Cheers,

Keith
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
Running two commands in one line rdns UNIX for Dummies Questions & Answers 4 04-27-2009 12:04 PM
Unix commands in one line miltonkeynesguy Shell Programming and Scripting 11 11-04-2008 10:49 PM
How to get nth line from a file usuing commands bsathishmca UNIX for Dummies Questions & Answers 3 09-26-2008 07:50 AM
Seperate commands on the same line bobk544 Shell Programming and Scripting 3 07-28-2007 06:14 PM
Commands and Command Line Flags Kedgeboy Shell Programming and Scripting 4 07-11-2005 11:23 AM



All times are GMT -4. The time now is 09:12 AM.