Hot answers tagged

10

Ksh93 does a lot to avoid forks. I have no idea how it knows how to handle the first case, as a truss shows that it only calls one write(2) call with the final result. It may be that David scans the command in macro.c and knows that he may handle "echo" internally. What I can say is that I rewrote the parser and the interpreter of the "Bourne Shell" last ...


2

Turns out it is documented behaviour. From the ksh93 man page: Search Edit Commands These commands access your command history. [count]k Fetch previous command. Each time k is entered the previous command back in time is accessed. [count]- Equivalent to k. [count][A If cursor is at the end of the line it is equivalent to / ...


2

grep -lZ max graham/quant/*.biz | xargs -0r maximum.sh grep -lZ milan graham/quant/*.biz | xargs -0r milan.sh grep -lZ min graham/quant/*.biz | xargs -0r minimum.sh Note: requires GNU grep for the -Z option to output NUL-separated filenames. These lines use grep's -l option to output a list of files containing the wanted pattern (max, milan, or min), ...


1

As the users says it is using an ancient unix shell, lets try another version of the script: #!/bin/sh #test version for ancient shell. cd graham/quant for file in *.biz do grep -q "max" "$file" if [ "$?" = "0" ]; then maximum.sh "$file" fi grep -q "milan" "$file" if [ "$?" = "0" ]; then milan.sh "$file" fi grep -q "min" "...


1

That's because underscore _ is a valid part of a variable name, so you also need the curly braces around FILENAME: NAME=${FILENAME}_${mdate}_${EXTENSION} Based on your other response, it appears that you also have a carriage return (\r) in either the FILENAME assignment line or the output of sqlplus, in $mdate. Find out which by running cat -v on your ...


1

magic_script dirdata dirfinal file1.txt $0 is the script_name (magic_script) $1 first argument dirdata $2 second argument dirfinal $3 third argument file1.txt ftp -divn XXX.XXX.XX0 << EOF! user user pass cd /home/dir1/dir2/dir3/"$1" lcd/home/dir11/dir22/dir33/"$2" get "$3" bye EOF!


1

To replace newlines embedded in records with spaces using GNU awk. num_fields=4 awk -v RS='([^|]*\\|){'"$num_fields"'}[^|]*\n' ' { n = split(RT, a,"|"); for (i=1; i<=n; ++i) { gsub("\n", " ", a[i]); printf "%s%s", a[i], i==n?"\n":"|" } }' file This gives 1|ABC|11|DEF|111 2|ABC|22|PQR ST UW|222 3|ABC|33|XYZ|333 4|ABC|44|...


1

The stat command is not standard. There's one on Linux, a more restricted one on embedded Linux, one with completely different options on FreeBSD and OSX, and none on most other Unix variants such as Solaris, AIX, and HP-UX. Your syntax looks like it's intended for Linux's stat. You're apparently running a system without stat. You probably don't have date -...


1

Pretty sure your error is meant to indicate that your shell: /usr/bin/ksh: Can't find "stat": stat: not found Does your operating system provide the "stat" command? You'll need to provide more information on your operating system and it's version for further guidance. You may also have a problem in your "PATH" environment variable.



Only top voted, non community-wiki answers of a minimum length are eligible