LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   #@!?£$# stdout problem!! (https://www.linuxquestions.org/questions/linux-newbie-8/%40-%A3%24-stdout-problem-42344/)

beedyrazzle 01-21-2003 06:50 PM

#@!?£$# stdout problem!!
 
I'm very new to shell scripting, and I need to append stdout to a file. I do this using

command >> file

this works fine, except that I want the data to be appended on the same line, with no space in between the existing data and the new data, for example, if stdout contains "", and tempfile contains "31", i get:

13
37

when i want 1337

:cool: :D

any ideas on how to do this (or maybe format a file so that everything is on 1 line??)

please help!!!! thankyou.

:newbie: :newbie: :newbie:

beedyrazzle 01-21-2003 06:52 PM

sorry, im my example, stdout should contain "37", tempfile should contain "13"

see im such a newbie i dont even know hwo to pyte propre;y yet

rnturn 01-21-2003 07:42 PM

Re: #@!?£$# stdout problem!!
 
Quote:

Originally posted by beedyrazzle
I'm very new to shell scripting, and I need to append stdout to a file. I do this using

command >> file

this works fine, except that I want the data to be appended on the same line, with no space in between the existing data and the new data, for example, if stdout contains "", and tempfile contains "31", i get:

13
37

when i want 1337


The problem isn't in how your are appending the `37'. The problem is that the `13' already has a newline appended to it by what ever placed it in the file. Try looking at the file at various points in the process using a command like `od -c /tmp/temp.file' (or whatever you called it).

If you were using `echo' to do this, you could do the following:

$ echo -e "13\c" > /tmp/temp.file
$ echo "37" >> /tmp/temp.file
$ cat /tmp/temp.file
1337
$

You can also use `echo -n' in linux but the `\c' special character is recognized by other UNIX shells without needing a special switch. Six of one...

Hope this helps...

Have fun.

unSpawn 01-21-2003 08:03 PM

echo -n "31" > /tmp/temp.file
echo "337" >> /tmp/temp.file


All times are GMT -5. The time now is 02:59 PM.