Computing.Net > Forums > Database > help with shell script

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.

help with shell script

Reply to Message Icon

Name: Josef
Date: February 16, 2009 at 17:29:40 Pacific
OS: Macintosh
Subcategory: General
Comment:

I have a file which has the following structure:
>sequence1
ACGUCGGAUCUGACUGUAUCG
>sequence2
ACGGUAUGUCUGUAUCUGUAUUCUG
>sequence3
ACGUAUCUAUCGUAUCUGAUC
...

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



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 17, 2009 at 06:58:05 Pacific
Reply:

I'm not a MAC guy, but this should give you a place to start. You might also have to use egrep:

#!/bin/ksh

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

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


0

Response Number 2
Name: FishMonger
Date: February 17, 2009 at 08:09:33 Pacific
Reply:

Or, instead of a shell script, you can use a simple perl command.

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Transfering Memory Cards cant get windows to start



Post Locked

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


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: help with shell script

Shell Script www.computing.net/answers/dbase/shell-script/599.html

executing shell script from pl/sql procedure www.computing.net/answers/dbase/executing-shell-script-from-plsql-procedure/741.html

need help with creating a table www.computing.net/answers/dbase/need-help-with-creating-a-table-/456.html