• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

bash shell script - Find word in text file

I have a text file that I want to hunt for an item then echo it.

The data in the file looks like this:

ITEM:  1411    DATE:  3/1/03

What I want to do is pull the number right after ITEM: and the date after DATE:, there are several spaces between ITEM: and the number as well as several spaces after DATE:

I want to put the following in a variable, so I can echo it later:
1411;3/1/03

Any ideas?

Thanks in advance!
0
cybrthug
Asked:
cybrthug
1 Solution
 
ozoCommented:
variable=`awk '/ITEM: .* DATE: /{print $2 ";" $4}' file`
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now