SED - log file format

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,

one way:

#  tr "\n" " " <infile

Hello matrixmadhan,

Thanks a lot for your help. You saved my day .. Thanks :slight_smile:

another way:

#  awk '{t=t" "$0}END{print t}' infile

Dear Tytalus,

Thanks for your reply.

your code is also working great. :b:

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?

Dear vgersh99,

I know that you are always around helping us :slight_smile: . 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

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

paste -s yourfile