Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Format Question

UNIX for Beginners Questions & Answers


Tags
awk, solved

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-12-2017   -   Original Discussion by DallasT
DallasT's Unix or Linux Image
DallasT DallasT is offline
Registered User
 
Join Date: Apr 2010
Last Activity: 12 December 2017, 10:11 AM EST
Posts: 161
Thanks: 35
Thanked 1 Time in 1 Post
Format Question

Hello friends

i have a file that outputs like this:



Code:
lineA
lineB
lineC

I would like it to format it like this as output:



Code:
'lineA','lineB','lineC'

Can you help?

Thank you
Sponsored Links
    #2  
Old Unix and Linux 12-12-2017   -   Original Discussion by DallasT
RavinderSingh13's Unix or Linux Image
RavinderSingh13 RavinderSingh13 is offline Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 19 January 2018, 2:18 AM EST
Location: Chennai
Posts: 2,689
Thanks: 594
Thanked 1,278 Times in 1,149 Posts
Hello DallasT,

Considering that your actual Input_file is same as shown sample Input_file, could you please try following and let me know if this helps you.


Code:
awk -v s1="'" -v s2="," 'val{printf s1 val s1 s2;} {val=$0} END{printf s1 val s1 RS}'  Input_file

Thanks,
R. Singh
Sponsored Links
    #3  
Old Unix and Linux 12-12-2017   -   Original Discussion by DallasT
DallasT's Unix or Linux Image
DallasT DallasT is offline
Registered User
 
Join Date: Apr 2010
Last Activity: 12 December 2017, 10:11 AM EST
Posts: 161
Thanks: 35
Thanked 1 Time in 1 Post
Worked beautifully my friend.

thank you!
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Question about awk format franksunnn Shell Programming and Scripting 5 06-17-2013 04:52 PM
Disk Format Question buckhtr77 Solaris 1 05-04-2009 08:00 PM
Date format question ajgwin Shell Programming and Scripting 2 05-20-2008 10:40 PM
Format question shorty UNIX for Dummies Questions & Answers 5 02-02-2006 04:56 PM
format and pkginfo -l question 98_1LE UNIX for Dummies Questions & Answers 4 03-06-2001 04:52 PM



All times are GMT -4. The time now is 05:43 AM.