bash: how to use first parameter of the command as a variable for other next parameters?
by postcd from LinuxQuestions.org on (#5CCF9)
Hello,
numerous times it happen that for example i want to duplicate file where the duplicate will only have different suffix, like:
Quote:
i would like to use first parameter as a variable for second one, like:
cp "long_file - name here! yaie.ext" "$1_backup"
(adding _backup suffix)
And what if i would like to use the incomplete name as the first parameter, like:
cp long_f* $1*_backup
What is the most simple way to do it please?


numerous times it happen that for example i want to duplicate file where the duplicate will only have different suffix, like:
Quote:
cp "long_file - name here! yaie.ext" "../long_file - name here! yaie - backup.ext" |
cp "long_file - name here! yaie.ext" "$1_backup"
(adding _backup suffix)
And what if i would like to use the incomplete name as the first parameter, like:
cp long_f* $1*_backup
What is the most simple way to do it please?