2,567 reputation
416
bio website
location The Netherlands
age
visits member for 1 year, 8 months
seen 2 days ago

“The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.”

"Daniel J. Boorstin


2d
comment Simple flag based comparison in Linux
That is because the variable FLAG_Control=false is set an yields always to true. The false there is misleading. It is not a boolean value as you are used to other programming languages. false is just a value that initializes FLAG_Control variable and sets it to true. FLAG_Control= which is not initialized yields to false.
Mar
25
comment Not able to rename root user of MySQL
Well, rename user command is introduced after mysql 5.0.2 version. You can check your version from the terminal using mysql -u newroot -p -e 'select version();' I personally believe that this is the best practice to rename root user. Thus, first creating a temp user and then rename the root user from there.
Mar
24
comment How to remove a particular character after a specific word
@don_crissti. I see. I might have been reading outdated tutorials.
Mar
24
comment How to remove a particular character after a specific word
@don_crissti the -E is the flag to enable Extended regular expressions on *BSD and Mac systems. Probably -r will be more desirable in this case since it will be compatible with GNU sed. FreeBSD did also add the -r option now to remain compatible with GNU sed.
Mar
24
comment How to remove a particular character after a specific word
To those who are downvoting the answer. Please write a comment at least to demonstrate the flaws in the answer. This way we all can provide better answers in the future. It could help me a lot to improve my writing and or explanation! Thanks!
Mar
24
comment How to remove a particular character after a specific word
You can do it using awk. For example: echo IBM, Inc.:APP-VM-Core:4.4.2.0:04, | awk '/IBM/{sub(/,/,"")}1'
Mar
24
comment can't split terminal using screen
I think it's worth to mention that by detaching the screen, splits won't persist. You need to create the split each time you enter the screen session.
Mar
20
comment SED command to format text file
I posted the answer which removes leading whitespaces.
Mar
20
comment SED command to format text file
This is a job that is more suitable to be done by awk. Off top of my mind awk -F';' 'BEGIN{OFS=",";} NR>1{ print $2,$3,"DATABASE"}' filename
Mar
19
comment BASH getopts problem
Well when it comes to quoting, you should always quote in bash unless you really really know what you are doing: "Double quote" every literal that contains spaces/metacharacters and every expansion: "$var", "$(command "$var")", "${array[@]}", "a & b". Use 'single quotes' for code or literal $'s: 'Costs $5 US', ssh host 'echo "$HOSTNAME"'. See mywiki.wooledge.org/Quotes , mywiki.wooledge.org/Arguments and wiki.bash-hackers.org/syntax/words
Mar
19
comment BASH getopts problem
Well I'm not really sure if I understand the purpose though. Feel free to improve the answer and provide some examples which demonstrates the caveats
Mar
19
comment BASH getopts problem
By point 7, I mean that moznostm= seems to be pointless. If it was a variable holding an integer, then there are situations a variable should be initialized as 0 so you could start counting or do other arithmetic calculations. In the setting as it is now, I don't see how moznostm= is going to help.
Mar
13
comment Some characters disappear after processing a text file
Doing with the shell only would suffice while read -r addr; do echo "${addr}.html"; done < addresses.txt
Mar
12
comment Replace \n with blank in a file
Oh, It seems I've been missing something! Thanks for pointing it out. I'm just leaving the answer here so other will know how to NOT do it.
Mar
11
comment Keep a tally from a log file
First of all. grep has -c option to do the counting itself. Also when you substract $b from $a you do it in a math context, meaning the syntax becomes echo $((a - b))
Mar
11
comment A sort of reversed cat
@Miline You now just need to substitute $2 with $1 and off you go!
Mar
11
comment A sort of reversed cat
This is a typical useless use of cat If I understand the question, the OP want's the first field only. That'd be awk '{print $1}' Doc1.lst There is no need for cat. awk can read a file as well.
Mar
10
comment Replace \n with blank in a file
In awk you'd do something like: awk '{ gsub(/\\n/,"") }1' file Also quite funny you use hashes # as substitution delimiters.
Mar
9
comment Push onto array with find exec
@AmadeusDrZaius This aproach does force read to use NUL byte as it's line delimiter. Since NUL is not a valid byte in unix filenames, this however is the safest place of feeding an array. See mywiki.wooledge.org/BashFAQ/020 for a better explanation.
Mar
5
comment Different Commands on Multiple Servers
If you have a file containing server addresses separated by a new line then you could probably use something as: i=0; while read -r server; do printf '%s %s\n' "./run$((++i))" "$server"; done < server_addresses. I'm not sure what your final goal is, but this should "hopefully" give you a clue.