Home » Infrastructure » Unix » sed .. inserts newline and spaces...
sed .. inserts newline and spaces... [message #133380] Thu, 18 August 2005 15:39 Go to next message
sumakads
Messages: 2
Registered: July 2005
Location: Detroit USA
Junior Member
I am using a sed funtion as follows...

if [ $FILE_EXT = "txt" ]; then
AFILENAME="F"$FILENAME
sed '1i\
'$AFILENAME'\
' $FILENAME > $FNAME
rm $FILENAME
mv $FNAME $FILENAME

I basically need to insert the name of the file, as the first line of the same file, starting with F.

But the output i get, inserts the filename correctly, but has 3 spaces in front. also ther eis a newline after the first line is added, How do i avoid this. any help please.

Thanks..
Re: sed .. inserts newline and spaces... [message #133496 is a reply to message #133380] Fri, 19 August 2005 06:51 Go to previous message
Frank Naude
Messages: 4581
Registered: April 1998
Senior Member
Do the following to see if the spaces are in your variables or not:

echo FILENAME=[$FILENAME]
echo AFILENAME=[$AFILENAME]


You can remove one newline by doing something like this:

sed '1i\
'$AFILENAME'' $FILENAME > $FNAME


Best regards.

Frank
Previous Topic: Oracle table to a file in Unix
Next Topic: DATE - DATE
Goto Forum:
  


Current Time: Mon Nov 25 22:00:08 CST 2024