ls
gives me:
10 11 12 12L 13 16 702 702L
etc., and I'd like to create files
10_ 11_ 12_ 12L_ 13_
and so on. But,
$ for f in *; do touch "$f_"; done
gives me:
touch: cannot touch '': No such file or directory
touch: cannot touch '': No such file or directory
touch: cannot touch '': No such file or directory
touch: cannot touch '': No such file or directory
Also,
$ for f in *; do touch $f_; done
gives:
Try 'touch --help' for more information.
touch: missing file operand
Try 'touch --help' for more information.
touch: missing file operand
Try 'touch --help' for more information.
touch: missing file operand
I have over 100 files in this directory and haven't intention to do this without script.
You could do it this way:
man bash
/EXPANSION says:However, this calls
touch
for every single file, which is quite inefficient. A better way is to letprintf
make a list of the files, zero-delimited in case of weird file names, and calltouch
only as often as needed with the help ofxargs
: