Put a string to the beginning of a file without a linefeed

Hello,

I need to put the following string to the beginning of a file - but it should not create a newline at the end of the string.

So, the file I have is a compressed one - with gzip.

And I would like to add an ASCII-String to the beginning of the file. The string has a length of 69 characters. For example:

'Xjunuolds 001.9092.12398734.Ght.x PPP.001 '

So, what I need is the following as example:

Xjunuolds 001.9092.12398734.Ght.x PPP.001 iei��)(/&%$jdd...

I tried to do it with a sed - I found with Google, but unfortunately a sed -i ... does not work, because the option -i is not supported...

Do you have any other solution?

If you edit the file and insert this, how will the file be unzipped later? gunzip will expect the content in specific locations that it controls and I would not rely on the extracted files. How would you expect gunzip to deal with this extra data?

What's the overall intention? Are you trying to edit the content of one of the zipped files somehow?

Robin

if you can put your string in a file (let's say file1):

printf "your string" > file1
#or
echo -n "your string" > file1

then you can do:

cat file1 file2 > file3

does it help?

1 Like

Tx for this quick help.

Sometimes a solution is so quite easy.... :b:

By the way, my intention to do this is to have a header for the delivery protocol - within this header (the ascii string) are infos for the delivery tool (i.e. the recipient). When the recipient will get this file, before the uncompressing he has to delete the header first...

CU,
API

your welcome,
anyway if you need it in a pipe:

{ printf 'your string single quoted is better' ; cat file2 ; } |  sendmail-or-other-command

enjoy shell scripting :smiley:

1 Like

Tx a lot. Thats exactly what I need...

That was a really good work... :b::smiley: