Visit Our UNIX and Linux User Community


output from sed getting truncated


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers output from sed getting truncated
# 1  
Old 09-18-2009
Question output from sed getting truncated

Hi all,

I have used sed command with a file of size 7KB and stored the output to another file.

When i look into the output file, a few file lines at the bottom have got truncated. The sed statement i used is as below. Why does this happen and how to resolve this.

SQL=`sed 's/#,MKT_TBL mkt#/Table_name/g' file1`


SmilieThanks in Advance for ur help.
# 2  
Old 09-18-2009
It could be because of flushing (when writing to your output file) not happening properly.

Try something like,

$sed 's/#,MKT_TBL mkt#/Table_name/gw outputfile' file1
# 3  
Old 09-18-2009
The fault is because you are trying to store the whole output file in an environment variable called $SQL and you have overflowed. There is rarely ever a reason to store more than one record in an environment variable.

The solution by "skmdu" writes straight to disc and is not limited to the maximum size of an environment variable.


A similar method is:

Code:
sed -e 's/#,MKT_TBL mkt#/Table_name/g' file1 > outputfile


BTW. The code you posted does not write to a file.
# 4  
Old 09-22-2009
MySQL

Methyl & Skmdu,

Thanks a lot for your help.

As Methyl said the problem was bcoz i used a variable to save my ouptut. I used a file for the process and it is working fine now.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #539
Difficulty: Medium
In C, int x; creates an integer variable associated with the identifier x initialized to one .
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ps -ef, output getting truncated, please help

Hi All, here is an output of my command and the problem is that my output string is truncated, I want to exact the full string, I am on BASH shell, please help me out. Regards Rahul command with Output : lonss05903:cmdsvc01 /home/cmdsvc01 > ps -aef|grep 'Copy' cmdsvc01 2642 8675 ... (7 Replies)
Discussion started by: rahulkalra9
7 Replies

2. UNIX for Advanced & Expert Users

Problem piping find output to awk, 1st line filename is truncated, other lines are fine.

Today I needed to take a look through a load of large backup files, so I wrote the following line to find them, order them by size, and print the file sizes in GB along with the filename. What happened was odd, the output was all as expected except for the first output line which had the filename... (4 Replies)
Discussion started by: gencon
4 Replies

3. Solaris

ps output truncated

Hi, I have Solaris-10 server. /usr/ucb/ps auxww is showing full path if I am running it from root. But if I run it from non-root user, its output is truncated. I don't want to use any other alternate command. Please suggest, what can be its solution. Terminal is set to term. (21 Replies)
Discussion started by: solaris_1977
21 Replies

4. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

5. UNIX for Dummies Questions & Answers

File gets truncated

Hi Guys, I have a master script file. That calls the other script files. The sub script files append some of the data to the log file. Once the master script completes one sub script execution and returns to execute other sub script that appends to the same log file. the log file gets... (2 Replies)
Discussion started by: Swapna173
2 Replies

6. Shell Programming and Scripting

File gets truncated after using sed

May be this is a known issue. When I am using sed to change a string (globally) in multiple files, it is doing its job while truncating the file. So the xml files are losing some of the tags Any work around? Appreciate your help guys...... Here is the code..... #!/bin/sh for files in... (2 Replies)
Discussion started by: corleone
2 Replies

7. Shell Programming and Scripting

Truncated with a pipe?

OK, I'm stumped. I have a shell script that reads a list, and for every item in the list performs a lookup in our Active Directory. Now, it seems that when I pipe the results into grep, the complete results are not there (truncated?). I'm not sure if this is a limit of the pipe, grep, shell... (1 Reply)
Discussion started by: TheCrunge
1 Replies

8. Solaris

ps truncated output

Hi Problem of ps on Solaris 8 and 9 Perhaps a silly question but I can't find a solution. the output of the command ps -ef is truncated. I've tried to change the terminal settings with stty putting a big number of colums: no change. Following the man page of ps i have set the variable... (8 Replies)
Discussion started by: renoc
8 Replies

9. UNIX for Advanced & Expert Users

ps output truncated

Hi! I have some shell scripts receiving in input lots of parameters and I need to select the ones having a particular value in one parameter. A typical shell command line is: PROMPT > shell_name.ksh -avalue_a -bvalue_b -cvalue_c -dvalue_d ... I used a combinaton of ps and grep commands... (5 Replies)
Discussion started by: pciatto
5 Replies

10. Shell Programming and Scripting

ps output truncated

Hi! I have some shell scripts receiving in input lots of parameters and I need to select the ones having a particular value in one parameter. A typical shell command line is: PROMPT > shell_name.ksh -avalue_a -bvalue_b -cvalue_c -dvalue_d ... I used a combinaton of ps and grep commands... (1 Reply)
Discussion started by: pciatto
1 Replies

Featured Tech Videos