Reputation
2,972
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
4 19
Newest
 Nice Answer
Impact
~155k people reached

May
6
comment bash - change filename in a loop
@CarlH basename(1) can strip the directory and extension from a path (directory/subdirectory/filename.extension -> filename.extension or filename). A parameter expansion can do it cleaner and much faster: "${path##*/}", "${path%.*}", at the cost of missing corner cases like path=/ For more see: mywiki.wooledge.org/BashFAQ/100?highlight=%28basename%29
May
6
awarded  Nice Answer
May
6
comment bash - change filename in a loop
oh really, I hope you are not serious. Quotes are crusial in bash for the above mentioned reasons. touch "file with spaces"; var="file with spaces"; cat $var && cat "$var" Notice the difference. In this case I'm using cat but imagine if one used rm. This will have very bad side effects. Avoid it if unnecessary! is just a bad advice.
May
6
reviewed Approve What is it that clobbers my letters together in Gedit?
May
6
comment bash - change filename in a loop
You should really make a habit to use more quotes just in case files contain spaces or new lines.
May
6
comment bash - change filename in a loop
@thiagoveloso as suggested, dir_in="/Users/dossa013/data/inland-data/input/" and dir_out="/Volumes/Macintosh HD 2/data/cmip5/cru/". Furthermore, you need to quote every expansion e.g "${f##*/}" and so on
May
6
comment bash - change filename in a loop
@thiagoveloso Using basename is discouraged. You are doing just fine using parameter expansion so keep using that.
May
6
comment bash - change filename in a loop
files=("/Users/dossa013/data/inland-data/input/"*ts*)
May
6
comment bash - change filename in a loop
Don't single quote '*' That won't expand. That's your problem.
May
4
revised How can I keep my SSH sessions from freezing?
Adding details about the NULL packet
May
4
comment Remove lines in a shell script
@StéphaneChazelas Thanks for the suggestion. The answer has been modified, feel free to provide a more portable solution.
May
4
revised Remove lines in a shell script
Update suggestion stephane
May
4
revised Remove lines in a shell script
added 211 characters in body
May
4
comment Remove lines in a shell script
Before providing answers let's wait and see what sie already tried. Nobody is expecting to spoon feed anybody.
May
4
answered How can I keep my SSH sessions from freezing?
Apr
30
reviewed Approve How do I update packages on Red Hat Linux?
Apr
30
comment IP address of the username who uses sftp connection in unix
using w -f should show you what protocol is being used and what is being accessed.
Apr
29
comment How to use md5sum for checksum with an md5 file which doesn't contain the filename
cmp test.txt.md5 <(md5sum test.txt | awk '{print $1}') && echo $? If the result returned is 0 then there is a match
Apr
29
comment kill: SIGSTOP: invalid signal specification error in bash script
Well ok, I didn't notice the -SIGSTOP I thought passing -s to kill was mandatory. Thanks for the explaination! Learnt something new today.
Apr
29
comment kill: SIGSTOP: invalid signal specification error in bash script
As I explained in my edited answer. set +o posix will allow the usage of SIGTERM, SIGSTOP etc. I do agree that set -o posix at the end is not necessary. It's more a habit. I'm not sure what the significance or the added value is in your answer.