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
COLORGCCRC(5)							File Formats Manual						     COLORGCCRC(5)

NAME
colorgccrc - configuration file for colorgcc DESCRIPTION
A colorgccrc configuration file is used to configure the highlighting of the compiler output from colorgcc. SYNTAX
Each line consists of a keyword designating a configuration variable. The keyword is followed by `:' and then one or several values (depending on the keyword). Lines beginning with a hash mark `#' are comments. CONFIGURATION VARIABLES
g++ | gcc | c++ | cc | g77 | gcj | gnat | gpc Specifies the paths to the compilers. Takes one value; a path to the compiler. nocolor Specifies what terminal types colorization should be disabled on. Takes one or several values, separated by whitespace. srcColor Specifies the highlighting attributes source-code should be given. Takes one or several color attributes. See the section COLOR ATTRIBUTES for more information. introColor Specifies the highlighting attributes for normal compiler output. Takes one or several color attributes. See the section COLOR ATTRIBUTES for more information. warningFileNameColor | errorFileNameColor Specifies the highlighting attributes for the filename in a warning or an error, respectively. Takes one or several color attributes. See the section COLOR ATTRIBUTES for more information. warningNumberColor | errorNumberColor Specifies the highlighting attributes for the line-number in a warning or an error, respectively. Takes one or several color attributes. See the section COLOR ATTRIBUTES for more information. warningMessageColor | errorMessageColor Specifies the highlighting attributes for the message-text in a warning or an error, respectively. Takes one or several color attributes. See the section COLOR ATTRIBUTES for more information. COLOR ATTRIBUTES
The following attributes are valid for highlighting. clear, reset bold, underline, underscore, blink, reverse, concealed black, red, green, yellow, blue, magenta, cyan, white on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white SEE ALSO
gcc(1), colorgcc(1) HISTORY
Jan 15 2003: Initial version of this manual-page. REPORTING BUGS
Report bugs to <jmoyers@geeks.com> AUTHORS
Jamie Moyers <jmoyers@geeks.com> is the author of colorgcc. This manual page was written by Joe Wreschnig <piman@sacredchao.net>, and modified by David Weinehall <tao@debian.org>, for the Debian GNU/Linux system (but may be used by others). COPYRIGHT
Copyright (C) 2003 Jamie Moyers This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. Jan 15, 2003 COLORGCCRC(5)
All times are GMT -4. The time now is 03:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy