Command on multiple lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command on multiple lines
# 1  
Old 10-10-2012
Command on multiple lines

I am writing a script and my command is long so it goes down to the next line, but it does not run properly, the pipe is missing the wc -l. how do i fix this problem.

Code:
find ${ARCHIVE}/${dir} -type f -name  "${TEMP2}*" | awk -F/ '{print $NF}' | wc -l

# 2  
Old 10-10-2012
You can break the line right after the pipe symbol, or you can break the line anywhere with a backslash (escaping the <newline> char):
Code:
ls |
> wc -l
11

Code:
ls | w\
> c -l
11

# 3  
Old 10-10-2012
why you need wc -l? if you are using awkSmilie


Code:
find ${ARCHIVE}/${dir} -type f -name  "${TEMP2}*" | awk -F/ '{print $NF}END{print NR}'

# 4  
Old 10-10-2012
Did you try to increase the line size...

Code:
export COLUMNS=130

# 5  
Old 10-10-2012
Quote:
Originally Posted by pamu
why you need wc -l? if you are using awkSmilie


Code:
find ${ARCHIVE}/${dir} -type f -name  "${TEMP2}*" | awk -F/ '{print $NF}END{print NR}'


I am just trying to return the number of occurrences of files with the same same before the extension. also I don't want to print what find does
# 6  
Old 10-10-2012
Quote:
Originally Posted by football12345
I am just trying to return the number of occurrences of files with the same same before the extension. also I don't want to print what find does
just remove print $NF then Smilie

Code:
find ${ARCHIVE}/${dir} -type f -name  "${TEMP2}*" | awk -F/ 'END{print NR}'

# 7  
Old 10-10-2012
Quote:
Originally Posted by pamu
just remove print $NF then Smilie

Code:
find ${ARCHIVE}/${dir} -type f -name  "${TEMP2}*" | awk -F/ 'END{print NR}'

I tried that, but it then prints

1
2
3
4
5

and I only need 5.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

sed remove multiple set of lines in one command

is there a way with sed to removed more than one set of lines in one line? so i mean sed ${firstElem},${lastIndex}d web.xml > web1.xml this will delete lines between ${firstElem},${lastIndex} i want in the same line to do somethinkg like this (doesn't work so far) sed... (3 Replies)
Discussion started by: Poki
3 Replies

3. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

4. UNIX for Dummies Questions & Answers

sed command, make multiple lines into one

:confused:Hi, I'm relativley new at unix so am having difficulties at the most basic of areas. I am trying using sed to make multiple lines into one line. For example, i would like: Mary had a little lamb to look like this Maryhadalittlelamb so far i have tried sed... (1 Reply)
Discussion started by: cavanac2
1 Replies

5. Shell Programming and Scripting

print multiple lines using the grep command.

Hi All, Please find my piece of code below. I am trying to grep the word SUCCESS from $LOGFILE and storing in the grepvar variable. And i am placing that variable in a file. Now if i open the file, i can see the four lines but not in seperate four line s but in a paragraph. If am mailing that log... (8 Replies)
Discussion started by: intiraju
8 Replies

6. Shell Programming and Scripting

How do I capture multiple lines of the status output of a command?

I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command: sh-3.2$ ftp -u ftp://username:password@computerdomain/directory/ file_to_be_uploaded Note: My environment allows me to issue... (2 Replies)
Discussion started by: zzz1528
2 Replies

7. Shell Programming and Scripting

Repeat same command on multiple lines

HI I have a text file named docs with 100 filenames with full directory path one by one. I want to perform an action on all of them, the action i want to do this chown bin:bin <filename>. The <filename> should be each line in the docs text file. Please give the code. Somebody told to use for... (2 Replies)
Discussion started by: PrasannaKS
2 Replies

8. UNIX for Dummies Questions & Answers

Sed command over multiple lines in csh??

hi i have a long sed command in a csh script that won't fit on 1 line. how do i break it up correctly over multiple lines? this doesn't seem to work in csh: sed -e s/template/$IP.$NN/ \ -e s/NRG/6/ \ -e s/inputf/$IS.$NN/ \ -e s/SHIFT/10.0/ <template.egsinp > $IP.$NN.inp i get: sed:... (1 Reply)
Discussion started by: tuathan
1 Replies

9. Shell Programming and Scripting

using sed command to replace multiple lines

the file contains the follwoing lines /* * Copyright (C) 1995-1996 by XXX Corporation. This program * contains proprietary and confidential information. All rights reserved * except as may be permitted by prior written consent. * * $Id: xxx_err.h,v 1.10 2001/07/26 18:48:34 zzzz $ ... (1 Reply)
Discussion started by: radha.kalivar
1 Replies

10. Shell Programming and Scripting

How to run awk command having multiple lines

Hi, Can u see the code below. set xyz = `cat testt1.txt | awk '/-----/{\ print $1 }\ ' | tail -1` I need to execute it in c shell . What is wrong with the above command. When i write everything on a single line then it is working. Can anybody help me . (0 Replies)
Discussion started by: nani_g
0 Replies
Login or Register to Ask a Question