I have a file containing string like: ./intercompany.rb[1:1] | passed | 9 minutes 7 seconds |
I want to remove the string coming after [ character. Output should be ./intercompany.rb
How can we do this in shell script??
s='./intercompany.rb[1:1] | passed | 9 minutes 7 seconds |'
echo "${s%%[*}"
See http://wiki.bash-hackers.org/syntax/pe and/or BashFAQ #100.