View on screen text file and enter input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting View on screen text file and enter input
# 1  
Old 04-03-2015
View on screen text file and enter input

Is the below correct syntax for if the user enters something other than "GJB2 or MECP2, or PHOX2B", then they are shown on the screen format.txt and allowed to enter in one of those formats? Thank you Smilie.

Basically, the user can see which formats are allowed and enter a variant while viewing the document?

Code:
[ "$gene" != "GJB2 or MECP2, or PHOX2B" ] &&
		printf "\n Please enter variant in one of the formats listed." &&
		cd 'C:' c:/Users/cmccabe/Desktop/Python27/format.txt
		less format.txt
		return
	printf "Enter variant(s): "; IFS="," read -a variants

# 2  
Old 04-03-2015
You can't do that while viewing a document. You can do that, or view a document, but not both simultaneously.

So I would put the less before everything, so they can see the document, then be told what to do with it once they quit. Perhaps with an option to view the file again if necessary.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 04-03-2015
Is it possible to enter the variant on that screen and then store that input as a variable. Then after the user enters the variant and hits enter it goes back to the function. I attached an example. Thank you Smilie.
# 4  
Old 04-03-2015
I will just echo the formats on-screen. Thank you for your help Smilie.
# 5  
Old 04-03-2015
I assume that what you meant by:
Code:
[ "$gene" != "GJB2 or MECP2, or PHOX2B" ] && ...

was:
Code:
[ "$gene" != "GJB2" ] && [ "$gene" != "MECP2" ] && [ "$gene" != "PHOX2B" ] && ...

Note that these comparisons are case sensitive. (In at least one of your other threads, you had "Phox2B" instead of "PHOX2B".)
# 6  
Old 04-03-2015
Is there a way to make them case insensitive? Thank you Smilie.
# 7  
Old 04-03-2015
Again assuming that you're using bash:
Code:
shopt -s nocasematch  # Use case-insensitive matches in [[ expr ]] and case patterns.
[[ "$gene" != "GJB2" ]] && [[ "$gene" != "MECP2" ]] && [[ "$gene" != "PHOX2B" ]] && ...

If you need case sensitive matches later in your script, you'll need to use:
Code:
shopt -u nocasematch

to restore the default case sensitive matching.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automatically enter input in command line

Hi, This is a script which to create an opvn user, I want which answer automatically to a certain part so, I try this, it works without the red part but I must type manually.. : #!/bin/bash ## Environnement ## LC_ALL=C ## Paths ## rsa_dir="etc/openvpn/easy-rsa"... (10 Replies)
Discussion started by: Arnaudh78
10 Replies

2. UNIX for Dummies Questions & Answers

How to enter special characters in a text file using vi?

Hi, I need to create a test text file with the special characters \342\200\223 in it and to be able to use sed maybe to delete them I tried doing it using vi by pressing CTRL-V and then typing 342 but it does not work. After pressing CTRL-V and typing 342 it seems to just insert the numbers... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Shell Programming and Scripting

Loop logic, enter into respective IF as per enter input file name

have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value File 1 export SERVER_CONNECTION=//dvlna002:10001/SmartServer File2 export SERVER_CONNECTION=///SmartServer File3 export... (1 Reply)
Discussion started by: Nsharma3006
1 Replies

4. Shell Programming and Scripting

function terminating if i give input as space or no input and enter

HI i have written a script to ask input from the user. this script should promote the user for y/n input. if user enters anyother input then y/n the script promotes him again. this below code is working fine for all the cases. except for space and enter " if i give space and enter it is... (2 Replies)
Discussion started by: BHASKARREDDY006
2 Replies

5. Solaris

How to view all the emails without scrolling over the screen

When I enter Solaris mail command, I get many emails on the screen on scrolling. How can I get it in one by one. BTW, if I delete the long list of emails by d command at the end, rest of the emails comes in one after other :rolleyes: Thanks... (0 Replies)
Discussion started by: wimaxpole
0 Replies

6. Shell Programming and Scripting

Enter an input and reference another line in ksh script

Hi I have a file like so: Code: Frank Peter Tony Robert Mike 1 2 3 4 5 5 4 2 3 1 4 3 1 5 2 My out should look like this: Peter Tony Mike and so on.... I have the first part done to ask the user to... (8 Replies)
Discussion started by: bombcan1
8 Replies

7. Shell Programming and Scripting

using read to enter the input at runtime

Hi I am stucked in the below script .I want to input with yes/no from the user and then execute the code inside if but it is not working .I just need the logic as where I am wrong so that i can use the same in my work . then echo "Hi All" fi ]. Please suugest . (4 Replies)
Discussion started by: mani_isha
4 Replies

8. UNIX for Dummies Questions & Answers

How do you view specific columns from a space delimited text file?

I have a space delimited text file with 1,000,000+ columns? I would only like to view specific ones (let's say through 1:10), how can I do that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

9. Shell Programming and Scripting

how to input answer (enter) if output contains a string?

how to wrote a script that reads an input from the reader (dir name) and then answer yes to all questions in the script unless the answer to any of the questions contains a certain string? example: $] script.sh dir_name $] question_1: (answer should be y right after the question is echoed,... (3 Replies)
Discussion started by: faizlo
3 Replies

10. Shell Programming and Scripting

Perl - Enter text in a file in a place.

Hi, I have a simple question: I need to enter some text in a text file at a certain place via perl. I would first need to find that specific text in the file and then I would like to insert a line after that particular line. Say I have this text file: I am a great Perl Programmer I... (1 Reply)
Discussion started by: som.nitk
1 Replies
Login or Register to Ask a Question