Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename.
for example:
I have file 111_123 that contains ACCOUNT:ABC1234567
cd /path/to/your/dir
for i in *
do
if [[ -f $i ]]
then
str=$(awk 's=index($0,"ACCOUNT:"){print acct=substr($0,s+8,10);exit(0)}' "$i")
[[ -n $str ]] && echo mv "$i" "$i.$str"
fi
done