help with shell script

February 16, 2009 at 17:29:40
Specs: Macintosh
I have a file which has the following structure:

I would like to extract only the first 15 characters of the lines that do NOT start with '>'.
Can anyone help me?

See More: help with shell script

Report •

February 17, 2009 at 06:58:05
I'm not a MAC guy, but this should give you a place to start. You might also have to use egrep:


rm -f datafile.tmp
grep -v '^>' datafile > datafile.tmp

while read line
   nl=$(echo "$line"|cut -c1-15)
   echo "$nl"
done < datafile.tmp

Report •

February 17, 2009 at 08:09:33
Or, instead of a shell script, you can use a simple perl command.

perl -ne 'print $1,$/ if /^([A-Z]{15})/' filename

Report •

Related Solutions

Ask Question