Can I spread commands over multiple lines?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can I spread commands over multiple lines?
# 1  
Old 06-07-2006
Can I spread commands over multiple lines?

Below an example of what I mean. The first attempt does what I want; the second doesn't, because bash assumes a line break means the end of an individual "command unix". Is there some way that I can convince bash to parse out, eg, to the closing parenthesis?

I'm thinking this would allow for neater looking scripts, specially if there are a lot of obscure parameters being passed in with hyphens.

Thanks!

Code:
$ls -l #l flag gives more output
insgesamt 4
drwxr-xr-x  2 hartmann users 144 2006-06-07 14:57 a
drwxr-xr-x  2 hartmann users 144 2006-06-07 14:57 b
-rwxr--r--  1 hartmann users 546 2006-06-07 15:01 diffem.pl
$( ls
> -l # l flag gives more output
> )
a  b  diffem.pl
bash: -l: command not found
$

# 2  
Old 06-07-2006
Use a backslash for line continuation:

Code:
ls \
-l

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove newline character from column spread over multiple lines in a file

Hi, I came across one issue recently where output from one of the columns of the table from where i am creating input file has newline characters hence, record in the file is spread over multiple lines. Fields in the file are separated by pipe (|) delimiter. As header will never have newline... (4 Replies)
Discussion started by: Prathmesh
4 Replies

2. UNIX for Beginners Questions & Answers

Use sed commands on multiple lines

I have a text file and i want to run 3 sed commands for the lines entered by the user using perl script. I am doing this manually till now. need some help with this The sed commands I have to use are : sed -i "s/{+//" error.txt sed -i "s/+}//" error.txt sed -i "s/\//g" error.txt... (5 Replies)
Discussion started by: utkarshkhanna44
5 Replies

3. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

4. UNIX for Advanced & Expert Users

Pass Multiple Commands and Open Multiple Xterms via PSS

Hello, I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else... (11 Replies)
Discussion started by: icemanj
11 Replies

5. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

6. Shell Programming and Scripting

[AWK] handeling data spread on multiple lines

Hello all, first off great forum. Now for my little problem. Using RHEL 5.4 and awk. Been doing code since a few month. So just starting. My problem is handeling data on multiple lines. { if ($1 != LASTKEY && h ~ /.*\/s_fr_/) { checkgecos( h, h ) h="" ... (2 Replies)
Discussion started by: maverick72
2 Replies

7. Solaris

Help with executing multiple remote commands after multiple hops

Hi SSHers, I have embedded this below code in my shell script.. /usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5` SSH to both these servers are public-key authenticated, so things run... (13 Replies)
Discussion started by: LinuxUser2008
13 Replies

8. Shell Programming and Scripting

search for a string spread in multiple line

Hi, I have to look for the full string below in a large file(>5GB) , but that string may be spread in two lines. string :-- "f8f8 f5f0 f0f0 f1f7 f4f7 f7c1" By grep "f8f8 f5f0 f0f0 f1f7 f4f7 f7c1" file | tail -1 , I am getting incorrect result because there is a line after this also which... (1 Reply)
Discussion started by: finder255
1 Replies

9. Shell Programming and Scripting

removing pattern which is spread in multiple lines

I have several huge files wich contains oracle table creation scripts as follows: I would need to remove the pattern colored in red above. Any sed/awk/pearl code will be of much help. Thanks (2 Replies)
Discussion started by: sabyasm
2 Replies

10. Programming

spawning multiple processes spread across two files

I want to spawn n child processes but have two different classes..with the foremost one forking/spawning the child process and the latter performing a function w/ the spawned processes. I can do this in one class with an if statement and the simple if((pid=fork())==0) //child process { ... (1 Reply)
Discussion started by: StrengthThaDon
1 Replies
Login or Register to Ask a Question