View Full Version : [ubuntu] [SOLVED] Multiple line commands
September 19th, 2008, 07:08 PM
I am attempting to work with command lines and have a basic problem in that I am unable to enter multiple command lines. Pressing enter only executes the line. For example how would I enter the following:
sudo depmod -a
sudo modprobe ndiswrapper
September 19th, 2008, 07:11 PM
You would enter one line, then press enter, then enter the next one, and so on.
Alternatively, you could string them all in one command, as in :
command1 && command2 && command3
The '&&' means "Wait until the previous command has returned ; if it returned OK, continue ; if it didn't, stop here".
September 19th, 2008, 07:12 PM
Just do it one line at a time.
However, you can execute multiple commands in one go. The syntax would be:
first command && second command && third command
Although obviously it might not be sensible to string everything together like this. So just do one at a time if you're unsure.
Top tip for cut'n'paste in Linux: just highlight the line to copy, then tap the mousewheel to paste into the terminal.
September 19th, 2008, 07:39 PM
Depending on what you want exactly ...
Use semi-colons for multiple commands :
command1; command2; command3
To split on multiple lines, use \
comand1;\ <enter> #<enter> == hit enter key
when you enter the second and third lines your prompt will change to a ">"
when you hit the enter after the 3rd command, all 3 will execute.
you can break lines anywhere you wish:
Logical constructs :
command1 && command 2
command 2 runs if command 1 is successful (no error messages)
command1 || command2
command 2 runs if command1 exits with an error
commmand1 & command2 => runs command1 in background and continues with command2
command1; command2 => runs command1 (in the foreground) then command2
sleep 10 ; ls
sleep 10 & ls
September 20th, 2008, 12:00 AM
this (http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html) link you will find basicly same answer as bodhi.zazen gave to you,but you will see same other command which you maybe find useful.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.