Skip to content

Instantly share code, notes, and snippets.

@sks147
Created May 13, 2021 04:43
Show Gist options
  • Save sks147/4b71b2ad823c524a17ec828cb6f8abba to your computer and use it in GitHub Desktop.
Save sks147/4b71b2ad823c524a17ec828cb6f8abba to your computer and use it in GitHub Desktop.
append_filename_to_beginning_of_file.sh
counter=1
for f in * ; do
file_name=$(basename $f);
split_file_name=(${file_name//./ });
file_name_without_extension=${split_file_name[0]}
gsed -i "1i # ${counter}. ${file_name_without_extension^^} \
" $file_name
((counter=counter+1))
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment