- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Simple awk - printf question
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
Discussions
Discussions
Forums
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
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
тАО04-21-2002 08:30 PM
тАО04-21-2002 08:30 PM
I am trying to process a file with uneven spaces (actually I found a pattern which is two or more spaces) to insert pipes as field delimiters and I am successful in doing so ... but I would like to keep the pipe for further processing in the shell script how do I do that ? I am not that familiar with printf ? Any help would be appreciated .. here is an example:
prompt>cat $testfile
string1<2spaces>string2<10spaces>string3<6spaces>....
prompt>grep "WF" ${testfile} | grep -i "online" | grep -v -i "gentrig" | sed 's/[ ][ ] */\|/g' | awk -F\| '{print $1,$6,$9,$10}' | while read SIEB_SRVR STATUS D
ATE TIME
but unfortunately the second field ($6 in this case) is a string with spaces and dashes ... so it is a hindrance for further processing and hence I want to keep the PIPE even after splitting the fields ???
Any ideas would be appreciated..
I found a workaround but would like to keep it simple ...
I can explain further if needed.
Thanks,
Shabu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2002 09:58 PM
тАО04-21-2002 09:58 PM
Re: Simple awk - printf question
I'm not quite clear about your requirements..if you aren't considering spaces as party of the string, have you considered doing a
tr -s " "
on the string first to eliminate duplicate spaces?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2002 10:12 PM
тАО04-21-2002 10:12 PM
Re: Simple awk - printf question
Never mind ... Deepak and All,
I fixed it ...
This is what I did:
-------------------
WKFS=`grep "WF" ${SMGR_LOG} | grep -i "online" | grep -v -i "gentrig"`
WKFS_TRIM=`echo "${WKFS}" | sed -e 's/[ ][ ] */\|/g' -e 's/ [0-9][0-9]/\|&/g'`
echo "${WKFS_TRIM}" | sed -e 's/\| /\|/g' -e 's/ /_/g' | awk -F\| '{print $1,$2,$6,$9,$10}' | while read SIEB_SRVR WKF STATUS DATE TIME
do
WF_STATUS_SCRATCH=`echo "${WKF}" | sed -e 's/_/ /g'`
WF_STATUS_ORIG=`grep "${WF_STATUS_SCRATCH}" ${SMGR_LOG} | grep "Running"`
if [ -z ${WF_STATUS_SCRATCH}" ]; then
print messages ...
notify etc..
fi
No need for any responses..
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2002 10:15 PM
тАО04-21-2002 10:15 PM
Re: Simple awk - printf question
still in the weekend mood. monday morning arrived too fast :-)
[N/A] pls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2002 07:31 AM