Cat writing only one record in the output file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cat writing only one record in the output file
# 8  
Old 02-08-2013
Hi Scrutinizer,

I am using below sequence of commands and I am getting only one record in the ouput file:

Code:
echo "HEADER|$nfnam" > $nfnam
cat Input.DAT >> $nfnam
echo "TRAILER|$fcnt" >> $newfilename

Sagar
# 9  
Old 02-08-2013
I notice the variables $nfnam vs. $newfilename again. Also, could you answer the questions in my previous post?
# 10  
Old 02-08-2013
Hi Scrutinizer,

Below is series of commands I am executing in a shell script:
Code:
echo "HEADER|$nfnam" > $nfnam
cat Input.DAT >> $nfnam
echo "TRAILER|$fcnt" >> $nfnam

I am getting as below:
Code:
HEADER|OUTPUT_B.DAT
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111
TRAILER|0000000002

What shell are you using, on what OS and version? --------- ksh
How do you running the script? --------- by giving name of shell script in the command line.

Could you copy and past the input file from the sample you posted here into a new file and test with that input file?
Code:
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|YY|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111
XXXXXXX|YYYYYYY|ZZZZZZZZZZ|12334446456|B|AA|111111111|111111111|111111111|111111111|15|3|NNNNNN|Y|3|AAA|111111111

Sagar

Last edited by Scrutinizer; 02-08-2013 at 03:51 AM.. Reason: code tags
# 11  
Old 02-08-2013
What OS and version
How exactly are you running the script?
With copy and paste I mean the other way around, copy it from this website and paste it into a file on which you can test your script..

also
what happens if there are 4 lines in your inout file?
# 12  
Old 02-08-2013
Pls post a binary or hex listing of your input file. Use e.g. od or hexdump.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wrong output when writing to file

Hello, I am having problem while redirecting output to a file where as on console output is proper. for dir in */; do printf "%s, " "$dir"; ls -m "$dir"; echo; done > output.txt Output of above command is coming in single line but when i am redirecting output to a file, single line i... (10 Replies)
Discussion started by: Manoj Rajput
10 Replies

2. Shell Programming and Scripting

Ssh cat file output into a file on local computer

Hello, I'm on a remote computer by SSH. How can I get the output of "cat file" into a file on the local computer? I cannot use scp, because it's blocked. something like: ssh root@remote_maschine "cat /file" > /locale_machine/file :rolleyes: (2 Replies)
Discussion started by: borsti007
2 Replies

3. Shell Programming and Scripting

Getting output with sed without writing to a file

HI I am trying to grep 3 characters from hostname and append a character at the end. I tried as in the following: root@abag3:~# hostname | cut -c1-3 hyu Now I am trying to append "g" at the end of this output as in the following. root@abag3:~# hostname | cut -c1-3 | sed -s... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

4. Shell Programming and Scripting

Writing output to a file in columns

Hi I am trying to write output to a file in columns I have file in the follwoing: # cat file abc def # I am trying to write next output as like # cat file abc 123 def 345 # :mad: (6 Replies)
Discussion started by: Priya Amaresh
6 Replies

5. UNIX for Dummies Questions & Answers

Cat Input & Output to a Log file

Team, we use below command to store the contents in a logfile. cat a.txt > a.log a.txt content is 123 345 Is there any options available to store the command used also? for eg a.log may show as cat a.txt 123 345 (5 Replies)
Discussion started by: sid2013
5 Replies

6. Shell Programming and Scripting

Getting output from a file similar to cat output

I have a file # cat /root/llll 11 22 33 44 When I cat this file content to a variable inside a shell script and echo that shell script, it does not show up as separate lines. I need echo output similar to cat. cat /root/shell_script.sh #!/bin/bash var=`cat /root/llll` echo $var (2 Replies)
Discussion started by: anil510
2 Replies

7. UNIX for Dummies Questions & Answers

Cat command drops lines in output file

I use the cat command to concatenate text files, but one of the rows I was expecting doesn't display in the output file. Is there a verbose mode\logging mechanism for the cat command to help me investigate where the lines I was expecting are going?? cat 7760-001_1_*_06_*.txt | grep -v... (1 Reply)
Discussion started by: Xin Xin
1 Replies

8. Shell Programming and Scripting

writing the output of SQL into one file

Hi All, Please help me writing the below script. I have two sql queries. 1. Select count(1),Client_id from TABLE_A group by Client_id; 2. Select count(1),Client_id from TABLE_B group by Client_id; I need the output of above two sql queries in a single file. The output 2nd query should be... (4 Replies)
Discussion started by: 46019
4 Replies

9. Shell Programming and Scripting

cat file and parse output

Hello, I'm new to shell scripting and did a search on the forum to what I want to do but couldn't find anything. I have about 9 routers that outputs to 1 syslog file daily named cisco.year.mo.date.log ex: cisco.2009.05.11.log My goal is to make a parsing script that cats today's syslog... (2 Replies)
Discussion started by: jjrambar
2 Replies

10. Shell Programming and Scripting

Writing given value into a file in particular record and column

Hi All, Could you ppl plz help me in writing into a file , plz find the example below. Ex: Name1|092387|Address1 Name2||Address2 After executing command/script the file should look like Name1|092387|Address1 Name2|+91900236|Address2 plz let me know of you have some solution... (4 Replies)
Discussion started by: shreekrishnagd
4 Replies
Login or Register to Ask a Question