I'm sorry if this has already been posted somewhere but I can't seem to find it on the forums (or anywhere on google )
I am writing a script where a user must enter a single character to perform an action.
For example, Press Q to Quit or R to Refresh
Basically I am stuggling to come up with a way you can use the read function to read one character (without pressing enter or return) and then perform a command based on what character you entered.
The only solution I can find is read -n but this isn't available for me.
I've used the following code to perform a timed out read which will wait 1 second and then continue the code but it takes too long.
Does anyone have any idea how to read single character without having to press enter?
Franklin52
When I try your method I get the following errors
funksen
When I try your method I get the following errors
It appears that I don't have the read -d, printf -v and cbreak functions.
---------- Post updated at 01:31 PM ---------- Previous update was at 12:54 PM ----------
Sorry to bother you again.
When I tried this previously, I just had a standard read command.
So I would press the key and then press return and the command would be fired.
Now that have the below code instead, I can't seem to capture the keypresses correctly
I used to have
This would determine whether the user was pressing up and down, q, a number or just pressing enter.
Now when I use the same code it isn't recognising the up, down or enter keypresses.
Have you any idea what I should change to get it to work.
Just to clarify, my code looks like the following.
Any suggestions would be much appreciated.
I have a csv dataset like this :
C,rs18768
G,rs13785
GA,rs1065
G,rs1801279
T,rs9274407
A,rs730012
I'm thinking of use like awk, sed to covert the dataset to this format: (if it's two character, then keep the same)
CC,rs18768
GG,rs13785
GA,rs1065
GG,rs1801279
TT,rs9274407... (7 Replies)
Hello everybody,
I am using Windows 10 and cygwin/bash.
I need to write a script in bash which simulates opening of a program and then press some keys such as F5, ENTER and ALT+F4.
I have written a VBScript which does the job
Set WshShell = WScript.CreateObject("WScript.Shell")... (9 Replies)
Hi friend,
I have one file , and i want to read that file character by character.
I need this script in ksh.
while using read option with -n1 am getting error.
while read -n1 c read has bad option
And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
I have a bash loop that waits for a single key press, then does $something depending on what $key is pressed before refreshing the screen with updated data. The problem I have is that the script will store additional key presses and chain them together causing the screen to redraw and the script... (1 Reply)
Hi all,
Greetings,
I have the following scenario, The contents of main file are like :
Unix|||||forum|||||||||||||||is||||||the||best
so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it
And i need the output in the following form:
Unix=forum=is=the=best
so=be=on=it
... (3 Replies)
hello all
i request you to give the solution for the following problem..
I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print
g
go
goo
goog
googl
google
like this Using unix Shell scripting...
without using... (1 Reply)
Hi,
I've made a script to grep a file
for i in `cat filename.txt`
do
strings ./binfile | grep "$i" 2>&1 > /dev/null
done
this works fine as long as in filename.txt i don't have any entries with spaces. But in my case i want to grep something with spaces like "lala tata"
and... (3 Replies)
Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/
Thanks! (1 Reply)
im having trouble doing this:
i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba
is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's?
im guessing its like getting the 1's compliment of the string
im doing this in... (2 Replies)