[SOLVED] Insert word between filename.
by ddenial from LinuxQuestions.org on (#4X44W)
Hello
How to insert a word in between a filename with spaces while cp or mv. For example in the following two examples, I do as follows:
Code:# ls -l /etc/vsftpd/vsftpd.conf*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
# cp /etc/vsftpd/vsftpd.conf{,.backup}
# ls -l /etc/vsftpd/vsftpd.conf*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
-rw-------. 1 root root 5113 Dec 27 20:12 /etc/vsftpd/vsftpd.conf.backupCode:# ls -l /etc/vsftpd/vsftpd*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
# cp /etc/vsftpd/vsftpd{,.PREFIX}.conf
# ls -l /etc/vsftpd/vsftpd*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
-rw-------. 1 root root 5113 Dec 27 20:15 /etc/vsftpd/vsftpd.PREFIX.confFollowing this method, how to insert some chars between filename with spaces.
For example, I want to copy the file 'A Sample File.txt' as 'A Sample TEST File.txt'
I tried these, won't work.
Code:# cp 'A Sample {,TEST} File.txt'
cp: missing destination file operand after 'A Sample {,TEST} File.txt'
# cp 'A Sample \{,TEST\} File.txt'
cp: missing destination file operand after 'A Sample \{,TEST\} File.txt'Thanks


How to insert a word in between a filename with spaces while cp or mv. For example in the following two examples, I do as follows:
Code:# ls -l /etc/vsftpd/vsftpd.conf*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
# cp /etc/vsftpd/vsftpd.conf{,.backup}
# ls -l /etc/vsftpd/vsftpd.conf*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
-rw-------. 1 root root 5113 Dec 27 20:12 /etc/vsftpd/vsftpd.conf.backupCode:# ls -l /etc/vsftpd/vsftpd*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
# cp /etc/vsftpd/vsftpd{,.PREFIX}.conf
# ls -l /etc/vsftpd/vsftpd*
-rw-------. 1 root root 5113 Dec 24 18:30 /etc/vsftpd/vsftpd.conf
-rw-------. 1 root root 5113 Dec 27 20:15 /etc/vsftpd/vsftpd.PREFIX.confFollowing this method, how to insert some chars between filename with spaces.
For example, I want to copy the file 'A Sample File.txt' as 'A Sample TEST File.txt'
I tried these, won't work.
Code:# cp 'A Sample {,TEST} File.txt'
cp: missing destination file operand after 'A Sample {,TEST} File.txt'
# cp 'A Sample \{,TEST\} File.txt'
cp: missing destination file operand after 'A Sample \{,TEST\} File.txt'Thanks