Aswex
November 3, 2009, 8:30am
1
Hello everyone,
I have a log file :
\data\file\script\command_0001
\data\file\script\command_0002
\data\file\script\command_0003
I need to make all lines on this way
\data\file\script\command_0001 \data\file\script\command_0002 \data\file\script\command_0003
I know this could be done with SED. But I am lost. Could you please help me on this ?
Thanks
awk '{ printf "%s ", $0 }END{ printf "\n" }' filename
---------- Post updated at 07:14 PM ---------- Previous update was at 07:13 PM ----------
or this,
Aswex
November 3, 2009, 8:49am
4
Hello matrixmadhan,
Thanks a lot for your help. You saved my day .. Thanks
another way:
# awk '{t=t" "$0}END{print t}' infile
Aswex
November 3, 2009, 9:09am
6
Dear Tytalus,
Thanks for your reply.
your code is also working great.
Thanks
---------- Post updated at 09:09 AM ---------- Previous update was at 08:52 AM ----------
Dear Friends,
If I may I have another question - The last one. Is there a way to make the file like it was ?
I have now
\data\file\script\command_0001 \data\file\script\command_0002 \data\file\script\command_0003
Is there a way to make it back like it was ?
\data\file\script\command_0001
\data\file\script\command_0002
\data\file\script\command_0003
Sorry for that question, but I have a huge amont of lines and I want to be sure that there is no corruption of that file.
Thanks
if
tr "\n" " " <infile
TRanslates newline ('\n') into spaces (' '), what do you think needs to be done to do the opposite?
Aswex
November 3, 2009, 9:50am
8
Dear vgersh99,
I know that you are always around helping us . Thanks for your reply.
It's about 20000 lines and I am too tired to check the all way to see if no line is missing or damaged. Your right, I will try to reverse the command line. I will see ...
Thanks vgersh99
code to put all the lines in one line:-
nawk -v ORS=" " '{print $0}' input_file
to reverse the command above:-
nawk -v RS=" " '{print $0}' input_file
BR
Aswex
November 3, 2009, 10:10am
10
Dear ahmad.diab
Code works great. Thanks for your help.
Problem solved. Thanks to all of you : )
for more easiness:-
code to put all the lines in one line:-
Code:
nawk -v ORS=" " '1' input_file
to reverse the command above:-
Code:
nawk -v RS=" " '1' input_file