0

Ignore the .bat extensions, just a habit from the old dos batch file days.

I have 2 simple shell scripts. I want to pass a filename with spaces (some file with spaces.ext) from little.bat to big.bat, as you can see below. It won't let me put the filename in single or double quotes.

First one called little.bat:

./big.bat some file with spaces.ext

Second one called big.bat:

cat template.iss | sed "s/replace123/$1/g" | sed "s/replace456/$1/g" > $1.iss

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
Josh Bond
  • 1,719
  • 4
  • 17
  • 26

2 Answers2

1

Escape spaces with another sed command.

you can fine details about the idea here: Escape a string for a sed replace pattern

Community
  • 1
  • 1
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
0

You can escape each space with a backslash:

some\ file\ with\ spaces.ext

That way, each space is passed on quoted, and the shell won't parse the space to mean "this is the end of one argument and the start of another".

Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
dandrews
  • 2,995
  • 1
  • 20
  • 22