LINUX how to generate multiple line output file


 
Thread Tools Search this Thread
# 1  
LINUX how to generate multiple line output file

Hi All,

I am trying to generate a file through a LINUX scripting as shown below

Code:
export field1=`cat dir/filename1.txt |wc -l`
echo "field1 : $field1 >>dir/WeeklySummaryReport.txt
export field2=`cat dir/filename2.txt |wc -l`
echo "field2 : $field2 >>dir/WeeklySummaryReport.txt

While checking the file, i could see the output is coming as a single line in the file. Can you pls help me with the command that I can add to my script to make the output into multiple lines.

Also, wondering whether we need to take care of anything if I plan to generate this report in html format.

Any thoughts will be much appreciated.

Thanks,
Freddie

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 03-12-2012 at 10:37 AM..
# 2  
Code:
wc -l *Report.txt >outputfile

?
# 3  
There are a couple of double quote characters missing in your script:

Code:
export field1=`cat dir/filename1.txt |wc -l`
echo "field1 : $field1" >>dir/WeeklySummaryReport.txt
export field2=`cat dir/filename2.txt |wc -l`
echo "field2 : $field2" >>dir/WeeklySummaryReport.txt

# 4  
Thanks for your reply.
I have resolved the syntax error in the LINUX script. But still getting the output as below,(with boxes)


Total SSN Suspects : 6880[]First Name + Last Name Suspects : 10201[]First Name + DOB Suspects : 9092[]Last Name + DOB Suspects : 149[]Total Initial Suspects : 10988

Any thoughts.

Thanks
Freddie
# 5  
Code:
... | sed 's/\[]/\n/g'

Code:
... | awk '{print $1}' RS=']' FS='['

Code:
# echo 'Total SSN Suspects : 6880[]First Name + Last Name Suspects : 10201[]First Name + DOB Suspects : 9092[]Last Name + DOB Suspects : 149[]Total Initial Suspects : 10988' | sed 's/\[]/\n/g'
Total SSN Suspects : 6880
First Name + Last Name Suspects : 10201
First Name + DOB Suspects : 9092
Last Name + DOB Suspects : 149
Total Initial Suspects : 10988

Code:
# echo 'Total SSN Suspects : 6880[]First Name + Last Name Suspects : 10201[]First Name + DOB Suspects : 9092[]Last Name + DOB Suspects : 149[]Total Initial Suspects : 10988' | awk '{print $1}' RS=']' FS='['
Total SSN Suspects : 6880
First Name + Last Name Suspects : 10201
First Name + DOB Suspects : 9092
Last Name + DOB Suspects : 149
Total Initial Suspects : 10988


Last edited by ctsgnb; 03-14-2012 at 05:11 AM..
# 6  
LINUX how to generate multiple line output file

Hi All,

I tried the below commands & it didnt work for me.

export a=/path/filename1.txt| cut -d ' ' -f1`
echo "Total recs : $a">>/path/Report.html | awk '{print $1}' RS=']' FS='['
export b=/path/filename2.txt |wc -l`
echo "b : $b">>/path/Report.html | awk '{print $1}' RS=']' FS='['

Also, i tried using the sed command below,

| sed 's/\[]/\n/g'

Still the 2 entries into the html file is coming in one line in the html file.
Can you pls shed some light on bringing this 2 output values in 2 separate rows in the html file.

Thanks much
Freddie
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Computers
Difficulty: Medium
Early RAM was directly seated onto the motherboard and could not be easily removed.
True or False?

10 More Discussions You Might Find Interesting

1. Linux

Generate output file

I would like to generate below one line report to output.txt file using csh. 01/01/09 10:15:47|APPL|MD5|ASCII-LF|6480|bal246b61fedf7e07220cedd1a100578 how to make the code to be worked ? Please advise.thanks in advance. #!/bin/csh a = date set s = '|' ... (3 Replies)
Discussion started by: balajikalai
3 Replies

2. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

3. Shell Programming and Scripting

Linux - Script to generate the output delimited by Comma/Pipe

Hi All, I have a requirement where I need to go to a directory, list all the files that start with person* (for eg) & read the most recent file from the list of files. While browsing through the forum, i found that the command ls -t will list the files. I am trying to generate the output... (1 Reply)
Discussion started by: dsfreddie
1 Replies

4. Shell Programming and Scripting

Read a CSV file and generate SQL output

Friends, This is what I need: I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location. I'm new to Shell scripting. I'm currently working on a... (25 Replies)
Discussion started by: Ram.Math
25 Replies

5. Shell Programming and Scripting

to read a CSV file and generate SQL output

Friends, This is what I need: I will pass a CSV file as an input, and I want my shell to be reading that CSV file, and based on the parameters it should generate SQLs and write those SQL in a different file in the same location. I'm new to Shell scripting. I'm currently working on a... (1 Reply)
Discussion started by: Ram.Math
1 Replies

6. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

7. UNIX for Dummies Questions & Answers

How to generate multiple lines in a text file?

Hello, I want to create a file whose content is multiple lines of strings. The string has the following pattern: aaaa/bbbb/A-B.txt A is a variable ranges from A1 to A2 B is a variable ranges from B1 to B2 Any ideas? Thanks. (17 Replies)
Discussion started by: vic005
17 Replies

8. Shell Programming and Scripting

need help in Parsing a CSV file and generate a new output file

Hi Scripting Gurus, I am trying to parse a csv file and generate a new output file. The input file will be a variable length in turns of rows and columns. output file will have 8 columns. we have three columns from the header for each set. just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies

9. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

10. UNIX for Dummies Questions & Answers

How to parameterize multiple search patterns and generate a new file

I have one file: 123*100*abcd*10 123*101*abcd*-29*def 123*100*abcd*-10 123*102*abcd*-105*asd I would like to parameterize the search patterns in the following way so that the user could dynamically change the search pattern. *100* and *- (ie *minus) *102* and *- The output that is... (6 Replies)
Discussion started by: augustinep
6 Replies

Featured Tech Videos