Shell Script Incremental


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Incremental
# 1  
Old 04-01-2011
Shell Script Incremental

I have a master sequence say

>Seq
ATGCGTA.......

That I want to repeat N no of times and each time the sequence is the same but the header changes in incremental numerical order

E.g.
>Seq1
ATGCGTA.......
>Seq2
ATGCGTA.......
>Seq3
ATGCGTA.......
.
.
.
.
>SeqN
ATGCGTA.......


Ultimately the user decides on the value of N

Does anyone know a quick way of doing this
# 2  
Old 04-01-2011
Code:
awk -v N=100 -v seq="ATGCGTA..." 'BEGIN{while(++i <= N)print "Seq" i RS seq}'

# 3  
Old 04-01-2011
Code:
$ num=10 #user input
$ ruby -e 'BEGIN{c=1;s=File.open("file").read};1.upto('$num'){|x| print s.gsub(/^>Seq/,">Seq#{c}");c+=1 }'
>Seq1
ATGCGTA.......
>Seq2
ATGCGTA.......
>Seq3
ATGCGTA.......
>Seq4
ATGCGTA.......
>Seq5
ATGCGTA.......
>Seq6
ATGCGTA.......
>Seq7
ATGCGTA.......
>Seq8
ATGCGTA.......
>Seq9
ATGCGTA.......
>Seq10
ATGCGTA.......

# 4  
Old 04-01-2011
If your shell is ksh93
Code:
#!/bin/ksh93

NUM=100
for i in {1..$NUM}
do
    printf "Seq%d\nATGCGTA......\n" $i
done

You can also use a sequence expression in bash but the value must be hardcoded into the sequence, i.e. {1..100}, because bash does not apply any syntatic interpretation to the content between the braces.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Incremental logic

Hi Guys, am trying to write logic to do incremental value using linux Example: a=00.00.00.01 My b should be like this b=00.00.00.02 and when it reaches 99 my b should look like this b=00.00.01.99 Appreciate your help guys Please use CODE tags when displaying sample input, sample... (14 Replies)
Discussion started by: buddi
14 Replies

2. Shell Programming and Scripting

Incremental numbering?

Would it be possible for a script to duplicate a file and incrementally number it? File in: XXX_007_0580_xxxx_v0016.aep File out: XXX_007_0580_xxxx_v0017.aep If someone knows of a way I'd love to see it. Thanks! (7 Replies)
Discussion started by: scribling
7 Replies

3. Shell Programming and Scripting

FULL or INCREMENTAL ???

Hi. Can someone tell me if the following script that i have made is a script for INCREMENTAL BACKUP or FULL BACKUP. My teacher told me that is doing an FULL BACKUP. • find /etc /var /home -newer /backups/.backup_reference > /backups/.files_to_archive • touch /backups/.backup_reference • tar... (1 Reply)
Discussion started by: bender-alex
1 Replies

4. Shell Programming and Scripting

Script for incremental file

Hi , I have incremental file FILE1 which locate in directory /asd/ This directory contains log files whose name entries goes in FILE1 how to make shell scripts for following condition shell script executes on day1 FILE1 entry ----> 1.log ... (3 Replies)
Discussion started by: kaushik02018
3 Replies

5. Windows & DOS: Issues & Discussions

Incremental Backup

I have a folder /root/test in a centos 5.3 system. I want to take an incremental backup of the contents of the folder in the C:\Downloads folder of a windows system present in the same lan as the linux system. What are the ways of executing this plan? Kindly help (0 Replies)
Discussion started by: proactiveaditya
0 Replies

6. UNIX for Dummies Questions & Answers

incremental by 1

let says, i have this number as 000002080, i want to add 1 to make it 000002081, and then i want to add 1 to 000002082, add 1 to 000002083, 84. i=000002080 TOT=$(echo "scale=9; $i + 1" | bc) echo $TOT it shows 2081, i want to retain 000002081, 000002082, 000002082, 000002084. (2 Replies)
Discussion started by: tjmannonline
2 Replies

7. Shell Programming and Scripting

Incremental backup

Hi, I would like to create a daily incremental backup of a directory with all of the files within and add a timestamp (year-month-day) to the tar.gz file. I have the following, but it doesn't backup the inside files of the directory. #!/bin/bash tar -czf... (1 Reply)
Discussion started by: agasamapetilon
1 Replies

8. Shell Programming and Scripting

[bash] Simple backup (cp) script but incremental

Hi all, I would need a rather simple bash backup script that loops throught the (local) users and for each users backs up (cp!) its /home/username folder. About the functionalities: The script has to run every 2 hours (that's cron, so don't mind about that) and the files should be copied to... (12 Replies)
Discussion started by: laurens
12 Replies

9. UNIX for Dummies Questions & Answers

incremental backup

Hi All.. i am trying to write a script which will give the incremental tar backup of all files with latest timestam. i tried with find -mmin -2 but if it takes half on hour or something to creat the tar itself, then no meaning in using the above command. so please help me to find the... (2 Replies)
Discussion started by: Usha Shastri
2 Replies
Login or Register to Ask a Question