Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Simple logging script that allows user to enter quick notes and questions, but I can not get it to pass punctuation '?. no matter what I type after 'n' i need that to be inserted at the end of the working project note file.
Any help and working examples would be appreciated, but please also direct me to the proper reading material so I can learn something - not looking for someone to just do it for me.
Well, in that case you might be better off to stay in The Other System.
...It's so deep inside bash that you will not be able to go around it.
...You better learn to live with that... Or make your own version...
Hi fruttenboel:
I appreciate you stopping by to chime in. I'm sure, because it is Linux, that it is possible and, with even more certainty, that someone is competent and helpful enough to contribute to solving it.
For other readers: The idea is to log notes quickly, without leaving the shell and not worrying so much about syntax. This is for a very fast-paced project where text is streaming and comments need to <be> made quickly, ten to twenty times per minute, then that info is appended to a text file that is accessed by another user where further comments are added to it, etc. So worrying about putting a quote or backslash in a comment is not an option, any more than using "'s while typing them
Thanks for any and all helpful posts - LQ rules - I'm learning a lot and thankful for the site.
bash has many special characters i.e * is used file name expansion. There are several ways to use these characters literally. You can use quotes for an entire string or \ with a single character. I am not aware of any option to turn off this feature.
Is the terminal window you are using to write comments used for streaming text too?
...Is the terminal window you are using to write comments used for streaming text too?
Hi Michael: The streaming text comes from several source (e.g. web, remote shell,etc.) but never the same screen. We review snippets of info from a database using another unrelated script 'q refno 1527' as an example would pull up just the note fields for that record and insert just that field into the log file, then we comment on the data presented and that comment is >> to the text log file
The apostrophe is the main concern, would be nice to make quick notes without needing to relearning how to type and without needing to remember to use quotations, trying to make it as quick and natural as possible... maybe I could replace the ' when it is typed with another character using sed or something... it's a challenge to figure it out, but not critical.
Meanwhile I'm reviewing the links you provided, thank you.
maybe I could replace the ' when it is typed with another character using sed or something
an alias would be better suited than sed/awk/... for this,
but the suggestion from michaelk (a script looping over lines read in) is probably better & safer
an alias would be better suited than sed/awk/... for this,
but the suggestion from michaelk (a script looping over lines read in) is probably better & safer
hi timmeke: I'm running with using read and learning lots. From what I'm reading, I should be able to come up with a functional solution, or at least have fun trying. thanks
MIchael: thanks again for steering me in the right direction and encouraging me to read more. As a newbie, I don't always know the correct terms to put in the search box, and you helped me figure it out, then BOOM, I had hours of reading to do, because I knew what to look for.
Read has tons of options and I'm having lots of fun learning. This is the promised follow-up - is this something like you had in mind? At any rate, it's working just fine and does exactly what I need it to do - quick and easy entry of notes without worrying so much about quotes and formatting.
thanks [all]
Code:
#!/bin/bash
# I left out all the sub scripts
mymenu () {
echo "e) Export Project"
echo "b) Book Entry"
echo "n) Notes"
echo "q) Query to Log"
echo "d) Exit"
}
while [ 1 ]
do
mymenu
read -s -n1 PRESSED
case "$PRESSED" in
"e")
echo "do export stuff"
;;
"b")
echo "do book stuff"
;;
"n")
echo "do note stuff"
;;
"q")
echo "do query stuff"
;;
"d")
exit
;;
esac
done
Last edited by dmafcoi; 05-22-2010 at 02:36 PM.
Reason: typo
What is the way to check if $var = one of the items on this list? Is a nested case the right/best way?
Also, how do I prevent the mymenu () from adding to the screen if I press a wrong key?
Code:
#!/bin/bash
mymenu () {
echo "abc"
}
while [ 1 ]
do
mymenu
read -sn1 PRESSED
case $PRESSED in
a | b | c)
case $PRESSED in
a) echo "you typed a";;
b) echo "you typed b";;
c) echo "you typed c";;
esac
;;
esac
done
Last edited by dmafcoi; 05-27-2010 at 01:09 PM.
Reason: typo
What was wrong with the code from post #12?
Typical response from a menu is when you press a wrong key an error message and the same menu items would be displayed again. You might want to use * case option if a b or c was not pressed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.