Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delimiting field

Status
Not open for further replies.
Apr 8, 2014
13
US
Text file example of about 150,000 lines:
Code:
1428590133:157:(scsi_eh_0):root:S:0:20:1:0:0.00:0.00:0.00:0.00:0.00:0.00:0.00:1:0:0:0:0:0:0:0:0:0:0
1428590133:158:(scsi_eh_1):root:S:0:20:1:0:0.00:0.00:0.00:0.00:0.00:0.00:0.00:1:0:0:0:0:0:0:0:0:0:0

I am using the colon as a delimiter.

However, I discovered that some records have a ":" in the third field:
Code:
1428595413:5316:(flush-253:10):root:S:0:20:1:0:0.00:0.00:0.00:0.00:0.00:0.00:0.00:0:0:0:0:0:0:0:0:0:0:0
1428595413:5317:(flush-253:11):root:S:0:20:1:0:0.00:0.00:0.00:0.00:0.00:0.00:0.00:0:0:0:0:0:0:0:0:0:0:0
1428595413:5355:(flush-253:0):root:S:0:20:1:0:0.00:0.00:0.00:0.00:0.00:0.00:0.00:1:0:0:0:0:0:0:0:0:0:0

How can I parse the fields using ":" because the third field is throwing me off?
Code:
timestamp=$1
pid=$2
cmd=$3
owner=$4
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top