Sponsored Content
Top Forums Shell Programming and Scripting Considerable trouble with for loop in combination with awk Post 302901501 by jfern on Wednesday 14th of May 2014 05:36:54 AM
Old 05-14-2014
Considerable trouble with for loop in combination with awk

I have the text file where each line has the format:

chr10 101418889 101418904 0.816327

Right now the interval between column 2 and 3 is 15. I only want the two consecutive positions starting at position 1, write it to a file, then move up one position write to file etc. So that:

File 1: chr10 101418889 101418990 0.816327
File 2: chr10 101418890 101418991 0.816327
File 3: chr10 101418891 101418992 0.816327
and so on...

My code so far:
Code:
for ((i = 0; i <= 14; ++1)) do
awk -v h=$i '{$2 += h; $3 += h-14; print}' original_core_files/lung.core.low.5SitesMin.bed > ../core_motif_singleton_controls/script/$i.bed;
done

The output is a "0.bed" file and a stuck loop.

As you probably see my programming experience is very limited, thank you very much for any form of help!

---------- Post updated at 04:36 AM ---------- Previous update was at 04:29 AM ----------

Solved:
naturally I should have put i++ instead of ++1, is there a way to delete embarrassing threads like this one?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk and file combination

Hi there, I have 3 files and i want to take different fields from each file and combine them in one. I would like to ask if somebody tell me how can I refer to each field of the different files to write an awk command. I mean can I do sth like awk '........... print $1.file1 $3.file2}'... (1 Reply)
Discussion started by: sickboy
1 Replies

2. Shell Programming and Scripting

Start more than one database - trouble with for loop

I have seen this done before - and maybe there is a better way too. I want to be abe to use a for loop (or other better method) to loop through the database instance names that are part of the script - not an external file where a read might be ok. Here is what I have and I know won't work -... (5 Replies)
Discussion started by: dave-mentor
5 Replies

3. Shell Programming and Scripting

Loop Trouble

Can anyone tell me what's wrong with my code here? I'm experiencing weird behavior... I am using 'j' to go down a list filenames saved in a .txt file and prompting the user whether or not she would like to delete each one. This works all well and fine the first run through, but then instead of... (2 Replies)
Discussion started by: RSymphony
2 Replies

4. Shell Programming and Scripting

for loop syntax trouble

i don't get what's wrong here. i'm writing a shell script that takes 1 argument (a number) from the command-line, but it's throwing an error: Syntax error: Bad for loop variable doesn't make much sense for (( i = 1; i = ${1}; i++ )) # error points to this line everytime do echo... (9 Replies)
Discussion started by: visitorQ
9 Replies

5. Shell Programming and Scripting

Sed Awk Cut Grep Combination Help ?

I have been reading for a few hours trying to educate myself enough to accomplish this task, so please know I have performed some research. Unfortunately, I am not a *NIX scripting expert, or a coder. I come from a network background instead. SO, here is my desired outcome. I have some Cisco... (5 Replies)
Discussion started by: abbzer0
5 Replies

6. Shell Programming and Scripting

Trouble with a file path as awk output in for loop

When I run the following command in the shell it works fine. It prints a city name and then a path for a file. ~$ for i in `awk -F':' '{print $0}' /home/knoppix/Desktop/data/subs | grep -m 1 $ city | sed "s/:/ /"` >do >echo $i >done Now, when I place it in this shell script (sh) it prints... (6 Replies)
Discussion started by: afroCluster
6 Replies

7. Shell Programming and Scripting

help with awk for file combination

1)file1: | *Local Communication Bandwidths (MB/Sec) | Memory copy (bcopy) | | ^ | mmap_bandwidth | | ^ | mmap_read bandwidth | | ^ | memory write bandwidth | | Local Communication Latencies | Pipe Latency | 2)file2 422.6903 1948.9000 ... (9 Replies)
Discussion started by: yanglei_fage
9 Replies

8. Programming

trouble with loop counting

HI there, I am trying to count manually what this code does but I am stuck and I don't learly see the result. The code works and it compiles and runs but I just don't follow the value of var. #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<unistd.h> #include<wait.h>... (2 Replies)
Discussion started by: bluetxxth
2 Replies

9. UNIX for Dummies Questions & Answers

Trouble understand and using for loop

Good evening all I have what might be a simple problem to solve but I do not know how to solve it myself. I am writing a bash script and my code looks something like this: mp3=`ls | grep \.mp3` for f in $mp3 do echo $f done Basically what I want to do is look through the current... (4 Replies)
Discussion started by: mistsong1
4 Replies

10. Shell Programming and Scripting

Combination awk and rename

Hello, i wondering if anybody can help me with the following: doing a search for the words "Sample ID:" in a file called test.txt and I need to have the string after this (Postmatch) Then I want that the string is used to rename an other file called test.pdf into .... the string.pdf I... (8 Replies)
Discussion started by: pcdok
8 Replies
Bio::FeatureIO::bed(3pm)				User Contributed Perl Documentation				  Bio::FeatureIO::bed(3pm)

NAME
Bio::FeatureIO::bed - read/write features from UCSC BED format SYNOPSIS
my $in = Bio::FeatureIO(-format => 'bed', -file => 'file.bed'); for my $feat ($in->next_feature) { # do something with $feat (a Bio::SeqFeature::Annotated object) } my $out = Bio::FeatureIO(-format=>'bed'); for my $feat ($seq->get_seqFeatures) { $out->write_feature($feat); } DESCRIPTION
See <http://www.genome.ucsc.edu/goldenPath/help/customTrack.html#BED>. Currently for read and write only the first 6 fields (chr, start, end, name, score, strand) are supported. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Allen Day Email allenday@ucla.edu CONTRIBUTORS
Sendu Bala, bix@sendu.me.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ _initialize Title : _initialize Function: initializes BED for reading/writing Args : all optional: name description ---------------------------------------------------------- -name the name for the BED track, stored in header name defaults to localtime() -description the description for the BED track, stored in header. defaults to localtime(). -use_score whether or not the score attribute of features should be used when rendering them. the higher the score the darker the color. defaults to 0 (false) use_score Title : use_score Usage : $obj->use_score($newval) Function: should score be used to adjust feature color when rendering? set to true if so. Example : Returns : value of use_score (a scalar) Args : on set, new value (a scalar or undef, optional) name Title : name Usage : $obj->name($newval) Function: name of BED track Example : Returns : value of name (a scalar) Args : on set, new value (a scalar or undef, optional) description Title : description Usage : $obj->description($newval) Function: description of BED track Example : Returns : value of description (a scalar) Args : on set, new value (a scalar or undef, optional) perl v5.14.2 2012-03-02 Bio::FeatureIO::bed(3pm)
All times are GMT -4. The time now is 07:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy