Computing.Net > Forums > Unix > Column Search on File Script HELP!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Column Search on File Script HELP!!

Reply to Message Icon

Name: mflair2000
Date: March 30, 2003 at 02:49:58 Pacific
OS: w98
CPU/Ram: 500
Comment:

i have to write a bourne program to perform a search of an employee list searching a specific column **only and outputing a different column of the same line..this is driving me absoluting crazy..any help would appreciated!!!

Columns
Information
01 - 11
Department
12 - 27
Player name
28 - 43
Target
44- 56
Team Name

Example of the " emplist " file... (The first two lines represent columns numbers, not in file)

EngineeringJohn Smith avinder Singh Rockets
Operations Karen Smythe John Smith Eagles
...
etc…

Sample execution:

$ as3
Player name? ohn
See target (T/t) or team name (M/m)? m
John Smith Rockets
Dean Johnson Eagles
Raj Johns Eagles




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 30, 2003 at 18:03:54 Pacific
Reply:

Hi:

The easiest was of parsing column type data is use the cut command:

Regards,

Nails

#!/bin/sh

while read line
do
dept=`echo $line|cut -c1-11`
echo $dept
pname=`echo $line|cut -c12-27`
echo $pname
target=`echo $line|cut -c44-56`
echo $target
tname=`echo $line|cut -c57-70`
echo $tname

done cdata.file
# need a less than error sign between done and data.file


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Column Search on File Script HELP!!

Korn script help!! www.computing.net/answers/unix/korn-script-help/4858.html

Need help on making scripts www.computing.net/answers/unix/need-help-on-making-scripts/195.html

Ksh script help www.computing.net/answers/unix/ksh-script-help/4204.html