I am trying to loop through all files located in a directory ending in .txt and rename them (replacing beginning with end). However I would like to take the output from this for loop and pipe it to a bash file so that I can check the file and make sure what I have written does what I want it to, then I can just execute the .bash file if what I see fits the task. I've tried
for file in *.txt ; do mv $file ${file//beginning/end} ; done | rename.bash
however this renamed the file and created an empty rename.bash
.bash
? I name all my bash scripts this way, I think it’s a good practice to have the interpreter as the script file extension, this way you see what’s ash
script and what’s abash
one without opening the file. – dessert Jan 03 '19 at 19:56.sh
scripts are typical for Bourne-shell scripts in general and extensions are generally a preference of the user/author :) There exit several/bin/sh
or/bin/bash
scripts on Ubuntu which don't use any extension at all either. A good example of that ison_ac_power
– Sergiy Kolodyazhnyy Jan 03 '19 at 20:06.py3
files won't even be recognized as modules. – wjandrea Jan 03 '19 at 20:34