- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Little help awk
Operating System - Linux
1753905
Members
9988
Online
108810
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО09-12-2006 08:06 AM
тАО09-12-2006 08:06 AM
Little help awk
Hello everybody, how you doing?
Can anyone help me in a case? I have a list with two names:
atibaia:/ # cat list
atibaia
aurora
I need to print this names between apostrophe, something like this:
'atibaia'
'aurora'
But, I need do this, using awk. I've tried some comands cat list | awk '{ print "'" $1 "'" } or cat list | awk '{ print "\'"$1"\'" }' and nothing... hahaha
Any idea to help me ?!?!?!
Thank you very much
Andr├й
Can anyone help me in a case? I have a list with two names:
atibaia:/ # cat list
atibaia
aurora
I need to print this names between apostrophe, something like this:
'atibaia'
'aurora'
But, I need do this, using awk. I've tried some comands cat list | awk '{ print "'" $1 "'" } or cat list | awk '{ print "\'"$1"\'" }' and nothing... hahaha
Any idea to help me ?!?!?!
Thank you very much
Andr├й
Andre Augusto
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 08:14 AM
тАО09-12-2006 08:14 AM
Re: Little help awk
You could set the single quote as a variable using the -v option:
$ cat list | awk -vqt="'" '{print qt$1qt}'
'atibaia'
'aurora'
$ cat list | awk -vqt="'" '{print qt$1qt}'
'atibaia'
'aurora'
Decay is inherent in all compounded things. Strive on with diligence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 08:34 AM
тАО09-12-2006 08:34 AM
Re: Little help awk
Great Jonathan...
Thank you very much for your help...
Regards
Andr├й
Thank you very much for your help...
Regards
Andr├й
Andre Augusto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 01:30 PM
тАО09-12-2006 01:30 PM
Re: Little help awk
I too couldn't figure out how many "\" are needed to quote the "'". But you could create an awk script with the "'" already there:
#!/usr/bin/ksh
cat < xx_list
atibaia
aurora
EOF
cat <<\EOF > awk_file
{ print "'" $1 "'" }
EOF
awk -f awk_file xx_list
rm -f xx_list awk_file
#!/usr/bin/ksh
cat <
atibaia
aurora
EOF
cat <<\EOF > awk_file
{ print "'" $1 "'" }
EOF
awk -f awk_file xx_list
rm -f xx_list awk_file
- Tags:
- awk
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP