Wow, thanks for all the help you guys!

Ming Hsu

On Tue, 19 Oct 1999, Baskette, John wrote:

> Hello,
> 
> I think you are looking for a short cut to handle a bunch of files.
> 
> Here is a script that will do this for you:
> 
>  #!/bin/sh
>  #
>  for file in $1
>  do
>    echo "1d\nw\nq" | ed -s $file
>  done
> 
> Let's call this script cut1.sh
> 
> The above is bourne shell, but it should work the same if you
> specify #!/bin/bash on the first line instead.
> 
> You invoke cut1.sh by entering a regular expression in single
> quotes on the command line.  For example:
> 
>  $cut1.sh 'cr*'
> 
> removes the first lines from all files that begin with cr in the current
> directory.  Of course, the script must have execute permissions (chmod +x
> <name_of_script).  
> 
> The above script uses ed for editing each file. "1d\nw\nq" says
> delete the first line (1d), write the file (w), and quit (q).  
> The \n are newline characters between the commands.  You could 
> use sed as in the following:
> 
> #!/bin/sh
> #
> for file in $1
> do
>   cat $file | sed '1d' > tmp$$
>   mv tmp$$ $file
> done
> 
> The problem with sed is that it copies the input stream, edits it,
> and sends it to the output stream making you use some kind of tmp file.  The
> older ed program copies the data to a buffer, edits it,
> and writes it back to the original file.
> 
> John Baskette 
> 
> > ----------
> > From:       Eugene[SMTP:[EMAIL PROTECTED]]
> > Sent:       Tuesday, October 19, 1999 10:34 AM
> > To:         Ming Hsu; [EMAIL PROTECTED]
> > Subject:    Re: Deleting the first line of text files
> > 
> > Edit file with <vi> and type <dd> on the line you want
> > to delete
> > (letter case is important!)
> > 
> > --- Ming Hsu <[EMAIL PROTECTED]> wrote:
> > > How can I delete the first line of a text file while
> > > retaining the
> > > formatting of the files?  I have a bunch of files
> > > with 360 columns of
> > > data, each for 1 degree.  The problem is that they
> > > are all labeled, and
> > > matlab takes in nothing but numbers, so I have to
> > > get rid of that first
> > > line.  I have looked at awk, but awk seems to do
> > > just columns.  Are there
> > > some other program that would allow me to delete a
> > > row of data?
> > > 
> > > Thanks,
> > > Ming Hsu
> > > 
> > > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Bid and sell for free at http://auctions.yahoo.com
> > 
> 

-- 
Ming Hsu

      "Gaius Petronius, a philosopher's learning,
                       with the courtier's ease."

                    -- Alexander Pope (of the arbiter elegentiae).

Reply via email to