File gets truncated after using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File gets truncated after using sed
# 1  
Old 09-19-2006
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 *.xml; do

mv $files $files.old
sed 's/OLD_STRING/NEW_STRING/g' $files.old > $files
rm -f $files.old

done
# 2  
Old 09-19-2006
can you show your input file before and after running the script ?
# 3  
Old 09-23-2006
When I opened source file in "vi" for which string replacement is to be made I see a message "Incomplete last line" at the bottom. Any idea? Btb this is an xml file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

KSH - Text from input file truncated while converting it to excel

Dear Members, I am using the attached script to convert a input file delimited by '|' to excel. However, while processing the attribute change_reason, the whole content of the text under change_reason is not displayed completely in the cell in excel. It is truncated after only first few words.... (1 Reply)
Discussion started by: Yoodit
1 Replies

3. UNIX for Dummies Questions & Answers

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... (3 Replies)
Discussion started by: madhan@29
3 Replies

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

5. HP-UX

How to Check Whether Core File complete or truncated

hi I have a core file from customer and i am looking for a way to know whether its complete or truncated? I have a procedure to check core file on solaris , is there any way to know whether core is truncated on HP-UX? from khan (1 Reply)
Discussion started by: khan_069
1 Replies

6. AIX

How to Check Whether Core File complete or truncated

Hi I am looking for a way to confirm whether a core File is complete or Truncated Is there any way from Khan (2 Replies)
Discussion started by: khan_069
2 Replies

7. AIX

PS truncated in AIX

folks; how can i get longer output than the one i got by using "/usr/ucb/ps awwx"? :mad: (2 Replies)
Discussion started by: moe2266
2 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
Login or Register to Ask a Question