Sponsored Content
Top Forums Shell Programming and Scripting Bash to select text and apply it to a selected file in bash Post 302982537 by cmccabe on Thursday 29th of September 2016 04:35:59 PM
Old 09-29-2016
Bash to select text and apply it to a selected file in bash

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 Smilie

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    [ "$panel" != "" ] && 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 ${panel} \n"
      read -r -p "Is this correct? [y/N] " response
if [[ $response =~ ^[nN][oO]?$ ]]
then
echo 'please try again'  && exit
else

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%%_*.vcf}
     grep -wFf /home/cmccabe/Desktop/ref/validation/panels/$panel $f >/home/cmccabe/Desktop/ref/validation/filtered/${pref}_filtered.txt
     echo "End filder creation: $(date) - File: $f"
done >> "$logfile"
line 32: syntax error: unexpected end of file


Last edited by cmccabe; 09-29-2016 at 05:48 PM.. Reason: fixed typo
 

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
panel_show(3CURSES)					     Curses Library Functions					       panel_show(3CURSES)

NAME
panel_show, show_panel, hide_panel, panel_hidden - panels deck manipulation routines SYNOPSIS
cc [ flag ... ] file ... -lpanel -lcurses [ library .. ] #include <panel.h> int show_panel(PANEL *panel); int hide_panel(PANEL *panel); int panel_hidden(PANEL *panel); DESCRIPTION
show_panel() makes panel, previously hidden, visible and places it on top of the deck of panels. hide_panel() removes panel from the panel deck and, thus, hides it from view. The internal data structure of the panel is retained. panel_hidden() returns TRUE(1) or FALSE(0) indicating whether or not panel is in the deck of panels. RETURN VALUES
show_panel() and hide_panel() return the integer OK upon successful completion or ERR upon error. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
curses(3CURSES), panel_update(3CURSES), panels(3CURSES), attributes(5) NOTES
The header <panel.h> automatically includes the header <curses.h>. SunOS 5.11 31 Dec 1996 panel_show(3CURSES)
All times are GMT -4. The time now is 10:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy