The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert UNIX file format to PC format Samtel UNIX for Dummies Questions & Answers 1 08-27-2009 03:29 PM
AWK CSV to TXT format, TXT file not in a correct column format mdap Shell Programming and Scripting 1 08-14-2008 12:03 PM
To convert multi format file to a readable ascii format gaur.deepti UNIX for Dummies Questions & Answers 5 03-25-2008 03:03 PM
Convert UTF8 Format file to ANSI format rajreddy UNIX for Dummies Questions & Answers 9 05-25-2007 09:26 AM
Convert UTF8 Format file to ANSI format rajreddy UNIX for Advanced & Expert Users 1 05-24-2007 07:40 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
Aswex Aswex is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 34
SED - log file format

Hello everyone,

I have a log file :

Code:
\data\file\script\command_0001
\data\file\script\command_0002
\data\file\script\command_0003

I need to make all lines on this way


Code:
\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
  #2 (permalink)  
Old 4 Weeks Ago
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960

Code:
awk '{ printf "%s ", $0 }END{ printf "\n" }' filename



---------- Post updated at 07:14 PM ---------- Previous update was at 07:13 PM ----------

or this,
Quote:
awk 'ORS = " " { print }END{ printf "\n" }' filename
Bits Awarded / Charged to matrixmadhan for this Post
Date User Comment Amount
4 Weeks Ago Aswex N/A 1,000
  #3 (permalink)  
Old 4 Weeks Ago
Aswex Aswex is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 34
SED - log file format

Hello matrixmadhan,

Thanks a lot for your help. You saved my day .. Thanks
  #4 (permalink)  
Old 4 Weeks Ago
Aswex Aswex is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 34
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


Code:
\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 ?


Code:
\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
  #5 (permalink)  
Old 4 Weeks Ago
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
one way:


Code:
#  tr "\n" " " <infile

Bits Awarded / Charged to Tytalus for this Post
Date User Comment Amount
4 Weeks Ago Aswex N/A 1,000
  #6 (permalink)  
Old 4 Weeks Ago
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
another way:


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

  #7 (permalink)  
Old 4 Weeks Ago
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
if

Code:
tr "\n" " " <infile

TRanslates newline ('\n') into spaces (' '), what do you think needs to be done to do the opposite?
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0