Good Code story

Written by Abhishri joshi

So this guy had many *txt files in a directory that he wanted to convert to *bak.

People told him- This– “for file in *.txt; do mv “$file” “${file%.txt}.bak” done” Or this–” for f in *.txt; do mv $f $(echo $f | sed ‘s/txt/bak’); done”

The issue with stuff like this is they are not efficient at all.

My solution– ls *.txt | xargs -I {} mv {} {}.bak

By doing this i can do this in parallel. Saving me time and increasing efficiency.

HOW YOU DO ONE THING IS HOW YOU DO EVERYTHING. I get called this is not pure shell. The thing is xorg is available since orignal unix systems. it is posix complaint hence pure shell. This is older then 50 years. It’s on on all macos, gnu/linux, all bsd systems.

After explaining this to the developers.
They all agreed.