gobot6
gobot6

Reputation: 133

How to extract partial input filename to name output file

I have a bash script (script.sh) that acts on a file called 12345.txt that currently produces an output file named "12345.txt_output":

Command line:

bash script.sh 12345.txt

Last line of script.sh:

> "${1}_output" 

How do I change the output command (while still using $1) to name the file 12345_output (instead of 12345.txt_output)?

Upvotes: 0

Views: 119

Answers (1)

karakfa
karakfa

Reputation: 67557

bash string functions

> "${1%.*}_output" 

Upvotes: 1

Related Questions