![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
sed question
I need to write a shell script for our first assignment at school that will seach through lines with each line having this same identical setup:
flightnum,landingcity,departurecity,aircrafttype,passengers,dtime,arrivtime 1050,Chicago,Miami,B737-800,150,7:00am,10:00am Basically it will search for the specific flight number, the first number before the comma in each line. After it find it the line needs to be deleted. Anyways, i'm sure i know how to search with sed using a specific string that the person will input but i'm not sure how to have it search just the first string in each line before that comma. Anyways this is what I have so far. function deleteflights { clear dispheader echo -n "Enter the flight number to delete: "; read flnum DATAFILE=/export/home/mpristav/gsufms/data/flight.data sed '/$flnum/d' $DATAFILE } if it weren't for the passengers somtimes matching the flight number I would just have it search for that number, however it must search using the first string on each line ONLY. Also note their will not be duplicate numbers so you just need to search for one. |
| Forum Sponsor | ||
|
|