I'm trying escape characters like \' but it doesn't work.
$ cp 'A long filen* ./short_filename
Your file does not contain quotes, it is a new output behavior of ls.
See: Why is 'ls' suddenly wrapping items with spaces in single quotes?
You can use
cp "A long file n"* short_filename
The * must be outside the quotes
or escape all spaces (and other special characters like \, ; or |, etc.)
cp A\ long\ file\ n* short_filename
If the filename includes single quotes you can escape them with \ or double quotes. You also have to escape the spaces though:
$ touch \'A\ long\ filename\'
$ ll
total 1
-rw-rw-r-- 1 jesse jesse 0 Jan 11 14:09 'A long filename'
You cannot escape the * for it to glob though so you must leave it outside the quotes:
$ ls -l \'A\ long\ file*
-rw-rw-r-- 1 jesse jesse 0 Jan 11 14:09 'A long filename'
$ ls -l "'A long file"*
-rw-rw-r-- 1 jesse jesse 0 Jan 11 14:09 'A long filename'
$ cp "'A long file"* ./short_file
$ ll
total 1
-rw-rw-r-- 1 jesse jesse 0 Jan 11 14:09 'A long filename'
-rw-rw-r-- 1 jesse jesse 0 Jan 11 14:11 short_file
GNU ls, at least, can also tell you how to quote something. In more recent versions its on by default, but even going back years you can do something like:
$ ls --quoting-style=shell
"'A long filename.mp4'"
There are other quoting styles available too; see the ls manpage.
You can also do something with printf (at least in bash):
$ printf '%q\n' *
\'A\ long\ filename.mp4\'
The %q means to print the argument out quoted (followed by \n, a newline), and * matches all the file names. So this is a sort-of-ls using printf.
Then after that, you just have to figure out how to add in your *. It needs to not be quoted, so in the two styles it'd be:
"'A long file"* # we've just cut a ""-quoted string short.
\'A\ long\ file* # that's just escapes, so cut it short.
cp "'A long file"* ./short_filedoesn't work for me. – M Ice Jan 11 '19 at 14:42