• Post Reply Bookmark Topic Watch Topic
  • New Topic

using split to extract some words from a file  RSS feed

 
carol maria
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I'm new in unix script and using the split command to find a specific word from a file and printout the info:

what i have in the script is as below:

#!/usr/bin/awk -f
# usage:
#
#
/Suppressing beats alerts until beats detected/
{
split($0,parts,"id=");
split(parts[2],bits,"]");
print stamp " = " bits[2]
}

and the output is like this: = is really dead. Suppressing heartbeat alerts until heartbeat detected.

the file contains:

id=abcdxxx001] is really dead. Suppressing beats alerts until beats detected.

expected output would be abcdxxx001 = is really dead. Suppressing beats alerts until beats detected.

but not sure what stamp should be equal to in the script.

Can someone help?

Thanks

Carol
 
Tomas Linhart
Ranch Hand
Posts: 86
2
Java Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with awk, but you can get required behaviour using sed:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!