- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- printing/escaping comma's in awk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 01:51 AM
03-05-2003 01:51 AM
I have the following (myfile.txt) :
1234567
abcdefg
2354324
3242323
8798799
I want to change this to :
'1234567',
'abcdefg',
'2354324',
'3242323',
'8798799',
hence wrapping the content for use with a SQL query.
I have tried the following :
cat myfile.txt | awk '{print("\'"$0"\'")}' myfile.txt > newfile.txt
cat myfile.txt | awl 'print{("\'%s\',",$1)}' myfile.txt > newfile.txt
but I am not getting any joy!
any suggestions would be appreciated thanks
John
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 01:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 02:03 AM
03-05-2003 02:03 AM
Re: printing/escaping comma's in awk
do a man on awk...
hope this helps...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 02:03 AM
03-05-2003 02:03 AM
Re: printing/escaping comma's in awk
'1234567',
'abcdefg',
'2354324',
'3242323',
'8798799',
#cat /tmp/b|awk -F "'" '{print $2}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 02:06 AM
03-05-2003 02:06 AM
Re: printing/escaping comma's in awk
should work...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 02:08 AM
03-05-2003 02:08 AM
Re: printing/escaping comma's in awk
you can use a single sed command:
sed "s/.*/'&',/" myfile.txt
rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 02:09 AM
03-05-2003 02:09 AM
Re: printing/escaping comma's in awk
hth
-balaji
$ cat a.txt
1234567
abcdefg
2354324
3242323
8798799
$ awk '{printf "\x27%s\x127 \n",$1 }' a.txt
'1234567'
'abcdefg'
'2354324'
'3242323'
'8798799'