Hi all, I'm having trouble coming up with a sed or awk to do the following...
I have a text file with lines that look like:
%let MYVAR = somevalue;
I need to replace somevalue (alphanumeric) with the value of a shell variable.
This I can do with
sed -i "s#\(%let MYVAR \=...
Thanks, that did it.
What's the difference between the implementations of /usr/bin/echo (whereis echo) and /bin/echo ? Is /bin/echo just what ksh uses?
for ARGUMENT in $* ; do
if [ -f $ARGUMENT ] ; then
echo $ARGUMENT
endif
done
you can also use
-a file true if the file exists (Korn/Bash)
-b file true if the file is a block special device
-c file true if the file is a character special device
-d file...
Whoops, I copied that wrong, it was:
NEWPATH=$(rl -p "Enter your name: " -d "Bob" 2>&1 >/dev/tty)
echo Hello, @${NEWPATH}@
produces...
Enter your name: Bob
@ello, @Bob
PHV: I tried this at your suggestion and thought it worked at first, but closer inspection of the result shows it is adding a carraige return or something to the result(I tried sedding out \r's \n's and \l's with no luck)
NEWPATH=$rl -p "Enter your name: " -d "Bob" 2>&1 >/dev/tty)
echo Hello...
FINALLY, I have exactly what I want by making a minor change to rl. I made the 3rd line from the bottom
fprintf (stderr,"%s\n", temp);
sending only the result to standard error. Then in the script I sent the stderr from rl to a file and used your solution for the rest.
rl -p "Enter your...
Almost, this gets the input into my variable, but rl still outputs the value on its own resulting in this:
Enter your name: Bob
Bob
Hello, Bob!
The problem is that the way readline is designed, all the input comes from one fd, and all the output goes to another fd, including the prompt :( The...
I think I know why this is happening, the prompt is actually being fed into the variable, not the terminal... How to separate the prompt into the terminal and the typed input into my variable???
Not really, the docs concentrate on readline's code, rl is an example program and doesn't really seem to be supported. (The C code for rl is has no internal documentation besides the usual GNU business...)
OK, thanks for that chipper, much easier than I expected. I've got rl working from the command prompt, but any way I try to capture the output from rl in a script, the -p prompt does not appear and none of my typed input appears until I press enter.
I tried newvalue=$(rl -p "..." -d "...") as...
Chipper: Although rl sounds great, I'm not sure how to go about installing a new command on an enterprise-wide system, I'm just a programmer recently getting into Unix scripting :)
tput does work much better thanks, but moving the cursor to the end of the path I want to edit does not let me...
Well, it seems knowitall's solution is limited afterall. You can only substitute up to 80 characters this way, and thats too few for my paths :( I thought this might have something to do with the default value of COLUMNS being 80, but when I changed it to 200, I still only got 80 characters...
OK, figured it out, here's how I did it using dtksh:
function vi_tab
{
if [[ "${.sh.edmode}" != "" && "${.sh.edchar}" == "=" ]] then
.sh.edchar=`echo "$LETVALUE" | sed 's/[ \t]*$//'`
fi
}
print "Enter a new path for this filename statement, press '=' to edit the old path:"...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.