×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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

Tags
awk, solved

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-12-2017
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 12-12-2017
RavinderSingh13 RavinderSingh13 is offline Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 13 July 2018, 10:31 AM EDT
Location: Chennai
Posts: 2,750
Thanks: 623
Thanked 1,316 Times in 1,183 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 12-12-2017
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
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:52 PM
Disk Format Question buckhtr77 Solaris 1 05-04-2009 07:00 PM
Date format question ajgwin Shell Programming and Scripting 2 05-20-2008 09:40 PM
Format question shorty UNIX for Dummies Questions & Answers 5 02-02-2006 03:56 PM
format and pkginfo -l question 98_1LE UNIX for Dummies Questions & Answers 4 03-06-2001 03:52 PM



All times are GMT -4. The time now is 08:44 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.