Skip to content

Tag: bash

Sed: select first part of price

Seems that my sed command is not working. I am trying to select the 2 in $2.99. However, no matter how I seem to type the regex, it will only give the .99 I want to select everything (every number) that is not the dollar sign up to the period. Any suggestions? echo “$2.99” | sed -e ‘s:^([^\$…

Linux Bash find files on user input with multiple -name clauses

I am trying to create small utility to collect log files from remote host by creating tar ball, for simplicity assume for now assume to just display list of files based on user input. This command works fine If i programmatically want to update -name clause based on the user input, say for example user input …

Expanding when one has command substitution

I have to echo an output of a command substitution concatenated with string. The string to be prepended is in fact the string of pathname. The need for use of absolute path together with filename arises due to filename containing special character,-, at the beginning of it. I’ve come up with a draft tha…

Bash script: too many arguments in [ test ]

I have the bash script below: When I run it: As you can see, when I don’t pass parameters ( $# -eq 0 ) it fails with “too many arguments”. So, I tested it directly in terminal: So, if it works perfectly in terminal why doesn’t it work passing parameters? Thanks, Answer Your entire expr…