Sponsored Content
Top Forums Shell Programming and Scripting Bash to select text and apply it to a selected file in bash Post 302982542 by cmccabe on Thursday 29th of September 2016 04:57:30 PM
Old 09-29-2016
Did I add it in the wrong place? Thanks.

Code:
FILESDIR=/home/cmccabe/Desktop/ref/validation/val
PANELDIR=/home/cmccabe/Desktop/ref/validation/panels

PS3="please select a panel: "

cd "$PANELDIR"
select bed in $(ls *.txt)
do    [ "$bed" != "" ] && break
done

PS3="please select a file to analyze with a panel: "

cd "$FILESDIR"
select file1 in $(ls *.vcf)
do    [ "$file1" != "" ] && break
done
      printf "FILE is: ${file1} and will be used filtered to ${bed} \n"
      read -r -p "Is this correct? [y/N] " response
    if [[ $response =~ ^[nN][oO]?$ ]]
         then
         echo 'please try again'  && exit
    else
    fi
logfile="/home/cmccabe/Desktop/ref/validation/val/process.log"
for f in /home/cmccabe/Desktop/ref/validation/val/$file1 ; do
     echo "Start filter creation: $(date) - File: $f"
     bname=$(basename $f)
     pref=${bname%%_*.txt}
     grep -wFf /home/cmccabe/Desktop/ref/validation/panels/$bed $f >/home/cmccabe/Desktop/ref/validation/filtered/${pref}_filtered.txt
     echo "End filder creation: $(date) - File: $f"
done >> "$logfile"
syntax error near unexpected token `fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

select in ksh, any guidance for bash?

I have a file driven menu using the select feature in ksh. I like doing it this way, however I would prefer running a bash. Is there some eqivalent way of doing this in a bash shell? ie select file in *.ascii  do typeset -u REPLY if  ; then... (1 Reply)
Discussion started by: Shakey21
1 Replies

2. Shell Programming and Scripting

Drop down menu in bash for timezone select

Is there any way to implement a drop down menu selection in bash? This is on CDLinux which is a very minimal live CD and I am using it to install an image onto a hard drive. Part of that process is the timezone selection. There are just too many timezones to attempt to use the "select" command.... (1 Reply)
Discussion started by: simonb
1 Replies

3. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

4. Shell Programming and Scripting

Select columns from a matrix given within a range in BASH

I have a huge matrix file which looks like this (example matrix): 1 2 3 5 4 5 6 7 7 6 8 9 1 2 4 2 7 6 5 1 3 2 1 9 As one can see, this matrix has 4 columns and 6 rows. But my original matrix has some 3 million rows and 6000 columns. For example, on this matrix I can define my task as... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

5. Shell Programming and Scripting

Reading a text file using bash

I've a file in linux with following text: ;ip address hostname put-location alt-put-location tftpserver 192.168.1.1 r01-lab1-net /mnt/nas1/fgbu/ /opt/fgbu/devicebackup 192.168.1.254Now I want to read these values and assign them to particular variables... (6 Replies)
Discussion started by: kashif.live
6 Replies

6. Shell Programming and Scripting

How to pass enter key or selected character in bash script?

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)
Discussion started by: kernel11
4 Replies

7. Shell Programming and Scripting

Bash to select panel then specific file in directory

I am using bash to prompt a user for a choice using: where a "y" response opens a menu with available panels that can be used. while true; do read -p "Do you want to get coverage of a specific panel?" yn case $yn in * ) menu; break;; * ) exit;; * ) echo... (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

Bash to select and save file in new directory

I am trying to select a file in bash and save it to a directory. The below does run but no selected file is saved. Thank you :). bash # select file printf "please select a file to analyze with entered gene or genes \n" select file in $(cd... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

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. select file in $(cd /home/cmccabe/Desktop/NGS/API/5-14-2016/bedtools;ls);do break;done files in directory 123_base_counts.txt 456_base_counts.txt 789_base_counts.txt second portion of bash currently (user... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

How can I apply 'date' command to specific columns, in a BASH script?

Hi everyone, I have a situation in which I have multiple (3 at last count) date columns in a CSV file (, delim), which need to be changed from: January 1 2017 (note, no comma after day) to: YYYY-MM-DD So far, I am able to convert a date using: date --date="January 12, 1990" +%Y-%m-%d ... (7 Replies)
Discussion started by: richardsantink
7 Replies
GIT-SYMBOLIC-REF(1)						    Git Manual						       GIT-SYMBOLIC-REF(1)

NAME
git-symbolic-ref - Read and modify symbolic refs SYNOPSIS
git symbolic-ref [-m <reason>] <name> <ref> git symbolic-ref [-q] [--short] <name> DESCRIPTION
Given one argument, reads which branch head the given symbolic ref refers to and outputs its path, relative to the .git/ directory. Typically you would give HEAD as the <name> argument to see which branch your working tree is on. Given two arguments, creates or updates a symbolic ref <name> to point at the given branch <ref>. A symbolic ref is a regular file that stores a string that begins with ref: refs/. For example, your .git/HEAD is a regular file whose contents is ref: refs/heads/master. OPTIONS
-q, --quiet Do not issue an error message if the <name> is not a symbolic ref but a detached HEAD; instead exit with non-zero status silently. --short When showing the value of <name> as a symbolic ref, try to shorten the value, e.g. from refs/heads/master to master. -m Update the reflog for <name> with <reason>. This is valid only when creating or updating a symbolic ref. NOTES
In the past, .git/HEAD was a symbolic link pointing at refs/heads/master. When we wanted to switch to another branch, we did ln -sf refs/heads/newbranch .git/HEAD, and when we wanted to find out which branch we are on, we did readlink .git/HEAD. But symbolic links are not entirely portable, so they are now deprecated and symbolic refs (as described above) are used by default. git symbolic-ref will exit with status 0 if the contents of the symbolic ref were printed correctly, with status 1 if the requested name is not a symbolic ref, or 128 if another error occurs. GIT
Part of the git(1) suite Git 1.7.10.4 11/24/2012 GIT-SYMBOLIC-REF(1)
All times are GMT -4. The time now is 03:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy