Hi I'm very new to this script thing, so please be gentle.
I am trying to get a command - the mach2qtl command in the code below - to loop through a set of files.
Each command should take the same two .dat and .ped files, but the .mlinfo and .mlprob files with filenames including 'chrom1' should be run together and output to a file PC_full_1.txt
I have run the command fine by retyping it using the appropriate file names, but would like to run this as a script that runs through files 1 - 22.
When I run the script below I get a segmentational error.
The error message "segmentation fault" comes directly from the OS. Somehow it tries to execute the program "mach2qtl" and this program crashes. This is definitely not a problem coming out of your script, at least not directly.
A little hint: if you have a loop which behaves strangely try to "echo" out all the commands in question. This way you will see (instead of execute) what is to be execute:
Modify this to:
to see if what you think is executed is really executed. In loops more complicated than this example this can widely differ.
Another possibility is to insert "set -xv" at the start of the loop and "set +xv" at the end. This sends every line as it is interpreted to stderr. ("set -xv" turns this on, "set +xv" turns it off). You can monitor the script as it is executed like this:
Lets talk about your script itself now:
While not directly incorrect this could be misleading to the shell: suppose you have two variables, "$i" and "$i_". How should the shell find out which one you mean? If you want to expand a variable in the middle of a string write it this way:
This will remove all ambiguity. Further, make it a habit to ALWAYS QUOTE your strings, because a misplaced (or unexpected) space character could well lead to disaster, because it is a separator to the shell. Therefore always write
and similarly for the other line in your script.
Btw., it seems that your variables "$infofile" and "$probfile" are not getting expanded, because otherwise there would be the contents of them in the error message.
Daily stupid question. I want to increment the file name everytime the script is run. So for example if the filename is manager.log and I run the script, I want the next sequence to be manager.log1. So to be clear I only want it to increment when the script is executed. So
./script... (10 Replies)
Hi all,
I want to generate output files in a loop, run the same command on the same input file 1000 times and output in files with a new name each time, maybe a number appended to it. The output will be different each time as I`m sampling randomly from the input file.
I want to do the... (3 Replies)
Hi there,
I've got a set of files that are named as follows:
image_N1_8letters.jpg
image_N2_8letters.jpg
...
image_N10_8letters.jpg
image_N11_8letters.jpg
....
image_N100_8letters.jpg
image_N101_8letters.jpg
with the "8letters" bit always consisting of 8 but always different... (3 Replies)
Hi,
I have some hundreds/thousands of files named logX.dat, where X can be any integer, and they are sequential, X ranges between 1 and any number:
log1.dat log2.dat log3.dat log6.dat log10.dat ... log6000.dat
I would like to rename them to
scatter_params_0001.dat... (6 Replies)
Hi again,
What i'm trying to accomplish here is search a large directory for certain filesames, read from a txt file and looping through it.
For instance, one of my target names from the loop file is:
1ad55f47-c342-496b-a46d-ba7de0f1b434
My loop is constructed thusly, run in a directory... (2 Replies)
Hi All,
Could you please help in this case?
Case: there's a directory 'CKMDB'
in this directory, there are 30 files named in this manner
1.txt 2.txt 3.txt .... 30.txt
Could you please guide me how to list only even numbered
files like 2.txt... (5 Replies)
I'm trying to search all .odt files in a directory for a string in the text of the file.
I've found a bash script that works, except that it can't handle whitespace in the filenames.
#!/bin/bash
if ; then
echo "Usage: searchodt searchterm"
exit 1
fi
for file in $(ls *.odt); do
... (4 Replies)
HIya,
Having a dumb day whilst writing an archive process in Shell want to extract from the filename the date and archive into tar files based on this, I don't want to use mtime as it may not be the actual file date.
The files are
-rw-rw---- 1 user admin 100 Aug 29 11:10... (2 Replies)
hey guys. i'm new to shell scripting but not new to programming. i want to write a script that will take all the files in the current directory that end with a particular filetype and change all their names to a number in order. so, it would take all the jpg files and sort them in alphabetical... (30 Replies)