Tag Info

Hot answers tagged

4

Note that the <<- word here-doc form requires that only tab characters can appear before word. You can't use spaces, must be tabs. ref: http://www2.research.att.com/sw/download/man/man1/ksh.html#Input/Output


4

sed -n -e '/[A-Z][A-Z][A-Z]/p' prints the lines that match that regexp. Here, you'd want: sed -n 's/.*\([[:upper:]]\{3\}\).*/\1/p' That is, you want to substitute a sequence of any characters (as many as possible) followed by 3 uppercase letters (captured in \1 with \(...\)) followed by a sequence of any characters with the captured letters and print ...


3

The problem is that the typeset creates the return status. This code (i.e. both assignments in the same declaration) works for me: typeset -r command_output=$(command) return_status=$? To keep the return_status writable (not read-only) you can do: typeset command_output=$(command) return_status=$? typeset -r command_output (i.e. declare the ...


2

lastUpdate="$(stat -c %Y myLogFile.log)" now="$(date +%s)" let diff="${now}-${lastUpdate}"


2

I can't say exactly for ksh, but from the experience with other shells - they cache current session history and push it to the file on exit. So history file removal affects on a new session, not the currently opened.


2

The other answers give solutions for sed and awk. If your sed and awk don't support multibyte characters, there's still a good chance that your bash does support them, so here is a pure-bash solution. First we choose a random number between 0 and the length of the string $a, inclusive, so that the string $b can be inserted between any two characters of $a, ...


2

The following works for me in mksh: $ echo $KSH_VERSION @(#)MIRBSD KSH R50 2014/10/07 $ x="Red,Yellow is a color,Blue" $ oIFS=$IFS $ IFS=, $ y=($x) $ IFS=$oIFS $ echo ${y[1]} Yellow is a color I believe it should work the same way in all versions of ksh.


1

I found part of the answer - @ is used for formatting text. For example, zwrite userid -m 'I like @(@color(purple) purple), but I don't like @(@color(green) green).' will produce a message with selectively colored text. More information can be found in the Zephyr documentation. That said, I'm still not sure what the escape character is, if there is one. ...


1

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet. su - db2prd<<EOF PARMDATE=1111111 echo parmdate echo \$PARMDATE EOF Or better, quote the delimiter (here EOF) to tell your shell not to perform expansions inside the here-document: su - db2prd<<'EOF' PARMDATE=1111111 echo ...


1

The following should work on any system with Perl: perl -pe 's/(>.*)(bar3)(.*<\/a>)/$1<font style=BACKGROUND-COLOR:red>$2<\/font>$3/' At least it does the right thing on your example file; the regexp in s/regexp/replacement/ asks to match bar3 between > and </a>, as you asked, but if your real-world HTML input is more complex ...



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