Reputation
2,217
Next tag badge:
143/400 score
25/80 answers
Badges
8 21
Newest
 Nice Answer
Impact
~117k people reached

Jan
29
awarded  Nice Answer
Jan
21
awarded  Custodian
Jan
21
reviewed Approve Formatting drives for Ubuntu
Dec
2
awarded  Yearling
Oct
11
awarded  Informed
Oct
5
awarded  Excavator
Oct
5
revised How to enter every directory in current path and execute script
added 127 characters in body
Oct
4
revised How to enter every directory in current path and execute script
Fixed broken code :)
Jul
1
awarded  Good Answer
Apr
24
awarded  Good Answer
Apr
1
comment How can I split a line in 2 by words/characters? (Bash) (Regex)
This and this. The main idea is that reserved variable names are in uppercase. If you use uppercase in your own variable names, you will one day have problems if you define PATH or HOME, etc. It actually happens very often that users define the variable PATH and then wonder why their script stops working all of a sudden. Latest to date is this one: stackoverflow.com/questions/29387616/…
Apr
1
comment How can I split a line in 2 by words/characters? (Bash) (Regex)
Good practice: 1. don't use uppercase variable names. 2. To get the number of characters in a string, use: chars=${#your_string}. Since you want half plus one: chars=$((${#your_string}/2+1)). This saves a subshell and a fork to external program (and saves from pathname expansion with your unquoted echo $YOUR_STRING). 3. Use more quotes: echo "$your_string" | fold -sw "$chars". Without the quotes for $your_string, you'll get surprises if your string contains glob characters like ?, *, [...] and extglobs constructs too if extglob is set.
Apr
1
comment How can I split a line in 2 by words/characters? (Bash) (Regex)
@user264974 the characters in the ranges A-Z and a-z are not wide characters, so it'll work fine with these.
Mar
31
comment How can I split a line in 2 by words/characters? (Bash) (Regex)
echo | wc is useless here. There are important quotes missing. This doesn't really show good practice. Also, be aware that fold counts bytes and not characters. So you will definitely get 3 lines or more if there are any wide characters.
Feb
26
revised What's the difference between shell builtin and shell keyword?
deleted 1 character in body
Feb
26
answered What's the difference between shell builtin and shell keyword?
Feb
24
awarded  command-line
Feb
2
comment How do I insert a line at the top of a text file using the command line?
@vp_arth If your content is in variable first_line then: ed -s filename < <(printf '%s\n' 1i "$first_line" . wq). Make sure that the variable doesn't expand to a single dot, and doesn't contain any newline characters (so sanitize it if it comes from user input).
Dec
2
awarded  Yearling
Nov
8
comment How to rename file extension to lowercase?
@KasiyA you know what? try it first on your own on a pendrive with a FAT32 partition. Then you'll see…