The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2005
Registered User
 

Join Date: Oct 2005
Posts: 1
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
  #2 (permalink)  
Old 10-17-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,334
Please make sure that you have read our rules. And note:
(6) Do not post classroom or homework problems.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0