Reputation
14,956
Top tag
Next privilege 15,000 Rep.
Protect questions
Badges
2 29 45
Newest
 scripts
Impact
~1.8m people reached

May
16
comment Most of the time I get '^?' instead of backspace action
Good, and what shell is it? echo "$SHELL"; ps -p "$$"
May
16
comment Most of the time I get '^?' instead of backspace action
What does echo "$TERM" output?
May
15
reviewed Approve Working with text files encoded as Windows-1250 and UTF-8
May
15
revised Working with text files encoded as Windows-1250 and UTF-8
Also show how to use recode on multiple files.
May
15
revised Working with text files encoded as Windows-1250 and UTF-8
added 197 characters in body
May
15
answered Working with text files encoded as Windows-1250 and UTF-8
May
15
comment Copy standard output to file
Assuming the script is bash, you can put exec > >(tee logfile) at the start of the script. (note that it is > >(...), not >>(...) nor > > (...). Whitespace matters.)
May
15
answered How to create a rotation animation using shell script?
May
15
comment How to debug bash script?
Avoid using uppercase variable names. Your risk overriding special shell variables and environment variables. Also, make sure you quote parameter expansions when they're used as arguments, to avoid word-splitting and pathname expansion occuring on the result. e.g. * ) eval "$cmd" ;; and debug_watch "$file" strange_case.txt.
May
13
comment changing string with sed, where did it go?
$file should also be enclosed in double quotes when it's used as an argument, to avoid word-splitting and pathname expansion occuring on the result. E.g. grep -q "public \$host = '127\.0\.0\.1';" "$file"
May
12
comment bash shell script
Don't use uppercase variable names for internal purposes. You risk overriding special shell variables and environment variables. And that just happened in your script there. UID is a special, read-only, shell variable that holds your uid. Any attempt to assign anything to UID will fail.
May
11
comment How can I capitalize letters before a certain character? (^)
@Serg, well it doesn't take much to get gawk installed. For instance, gcc depend on gawk, and quite a lot of other packages too (apt-cache rdepends gawk), since mawk 1.3.3 is rather useless for many things. And gawk automatically overrides the /usr/bin/awk symlink when it gets installed. I don't quite understand why Ubuntu bothers keeping mawk 1.3.3 from 1996 as the default awk, really. Should either upgrade to a recent version of mawk or switch to gawk.
May
11
comment How to change the color of stdout content?
I'd recommend using tput instead of hardcoding the terminal escapes. Also, the $(echo -e ...) is redundant; PS1 will already treat \e as ESC. And lastly, lines will now wrap around incorrectly because you forgot to put the terminal escapes within \[ and \]. See BashFAQ 53. EDIT: missed the point this was in your .mkshrc, but this will break for bash, which is what the questioneer is using.
May
11
comment How can I capitalize letters before a certain character? (^)
Note that if awk is mawk (the default), non-ascii letters will not be uppercased. gawk supports this, though, so if you install gawk it will handle such letters. Check which awk you have with awk -W version. (If you're still at mawk, I recommend installing gawk, since the mawk is 19 years old, and not POSIX-compliant)
May
11
answered How can I capitalize letters before a certain character? (^)
May
11
comment How to execute an script as daemon with nohup?
Why nohup? you won't be able to send SIGHUP to the process after that.
May
11
comment bash script to check if input has an @
ksh's read also has a -p option, but there it means "read from coprocess" instead of "use this as prompt".
May
11
comment bash script to check if input has an @
See this about the rational for removing the -number form. I doubt any existing implementations of head will remove it though. There's still a lot of code that use the "old" style.
May
11
comment bash script to check if input has an @
POSIX read only has one option, -r, so the first sh example should use printf to print the prompt. And using head -1 is obsoleted in favour of head -n 1
May
7
revised Run a shell script as another user that has no password
disabling highlighting of the code-blocks