Command line argument question 4 need ansswer

This script creates a backup of a given file by creating a copy as bkp

For example some-file is backed up as some-file_bkp

set -e

file_name=“some-file”

cp “$file_name”“${file_name}_bkp”

echo “Done”
cp: missing destination file operand after ‘some-filesome-file_bkp’

did i missed anything need answer

I’m not sure if this is a result of our forum software mangling your text, but the program you’ve pasted has the wrong kind of quote marks; you want simple ASCII double quotes.

You may want to edit your program to use a code box, like this:

set -e
file_name="some-file"
# and so on...

Yeah, discourse has changed the quotes, but even with the correct quotes, what we have here is

set -e

file_name="some-file"

cp "$file_name""${file_name}_bkp"

echo "Done"

and would result in the same error. There is a missing space…

cp "$file_name" "${file_name}_bkp"

will achieve the desired result.

1 Like