Use same file selected in first bash process that has matching digits in it fot the second
In the below portion of a bash script the user selects a file from a directory.
second portion of bash currently (user manually selects the file)
What I am trying to do is if the user selects 123_base_counts.txt in the first select, then in the second select whatever the name of the file in the annovar directory, the one that starts with 123 is used. The files will always have a _ in them. However my attempt seems to have flaws in it that I am not sure how to fix. Thank you .
The directory in the second select has files names:
Bash attempt
I can manually select each file but I am not sure how to automate the selection. Thank you .
Last edited by cmccabe; 07-23-2016 at 01:56 PM..
Reason: fixed format
Hi - This is only rough but something like the below should work on your data:
This makes the assumption that:
There is only 1 file in the 'annovar' directory which has the same prefix (delimited by an underscore) as the associated file in the 'files' directory and it exists
This is not just applicable for '123_' but for all files
Sorry about that, I've amended the script slightly so it should work as expected now:
It looks like basename isn't really required as you are dealing with the file names themselves straight from the select loop. Then when you create the file1 variable you append the directory in front of it.
As part of a bash the below line strips off a numerical prefix from directory 1 to search for in directory 2.
for file in /home/cmccabe/Desktop/comparison/missing/*.txt
do
file1=${file##*/} # Strip off directory
getprefix=${file1%%_*.txt}
... (5 Replies)
In the bash below I am asking the user for a panel and reading that into bed. Then asking the user for a file and reading that into file1.Is the grep in bold the correct way to apply the selected panel to the file? I am getting a syntax error. Thank you :)
... (4 Replies)
In the bash below the user selects the file to be used. The digits of each file are unique and used to automatically locate the next file to be used in the process. The problem I can not seem to fix is that the full path needs to be referenced in the second portion and it is not currently. Is... (7 Replies)
Hi I have a problem, I am attempting to write a bash script that goes through a file and can determine how many characters are at a set point in a line starting with QTY+113:100:PCE, If it detects 3 digits (number in bold) then pad it out with 12 zero's
If there are only two digits then pad it... (8 Replies)
two files: one with the line number only, and the 2nd one with line number and content, as following:
line_file.txt
1
3
5
9
23
30
content_file.txt
1|we are the world|good|great
2|easily do this by highlighting you|easily do this by highlighting you|easily do this by highlighting... (2 Replies)
hi,
i've bash script thats working...
but now i need to add a line....that prompts for user input....like yes and 1 as complete install....
so here's how it looks...
$ cd 9200 (cd into directory)
$./install (hv to type ./install to run install then ask for)
----do you want to... (4 Replies)
Hi there, im sure this is really simple but i have some strings like this
e1000g123001
e1000g0
nge11101
nge3and i want to create two variables ($DRIVER and $INSTANCE). the first one containing the alpha characters that make up the first part of the string, e.g. e1000g or nge and the... (9 Replies)
I have a file with hundreds of records and I need to find those records that have three digits at the beginning and the same three digits at the end.
$GREP '\(\)\(\)\(\)\3\2\1'I
believe this is part of the script but I am not sure how to compare these 3 digits with the 3 digits at the end of... (2 Replies)
Below is a test script to illustrate a problem from a larger script I am writing.
$ cat /tmp/loggingtest
#!/bin/bash
lvcreate -s -l 100%FREE -n var-data-snapshot vg00/var-data 2> >(logger -t "loggingtest.crit") 1> >(logger -t "loggingtest.info")
sync &
wait
lvremove -f... (1 Reply)
I have an if statement where I state that if there are more than one records (lines) found containing a string in a file, then it enters into a while loop to use each line for as many lines as there are and then stop.
Trouble is, I can't figure out how to move to the next instance of each line. ... (2 Replies)