Skip to main content
added 1 character in body
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

You could do something like

for f in ./*
do 
gzip -cdfq "$f" > "${f}".some_ext
done

This processes all files (even the uncompressed ones, via -f) and writes (via -c) the output to stdout using redirection to save the content of each file to its .some_ext counterpart. You could then remove the originals e.g. with bash

shopt extglob
rm -f ./!(*.some_ext)

or zsh

setopt extendedglob
rm -f ./^*some_ext

You could even save the resulting files to another dir (this time assuming you want to remove the original extension) e.g.

for f in ./*
do 
gzip -cdfq -- "$f" > /some/place/else/"${f%.*}".some_ext
done

and then remove everything in the current dir...

You could do something like

for f in ./*
do 
gzip -cdfq "$f" > "${f}".some_ext
done

This processes all files (even the uncompressed ones, via -f) and writes (via -c) the output to stdout using redirection to save the content of each file to its .some_ext counterpart. You could then remove the originals e.g. with bash

shopt extglob
rm -f ./!(*.some_ext)

or zsh

setopt extendedglob
rm -f ./^*some_ext

You could even save the resulting files to another dir (this time assuming you want to remove the original extension) e.g.

for f in ./*
do 
gzip -cdfq "$f" > /some/place/else/"${f%.*}".some_ext
done

and then remove everything in the current dir...

You could do something like

for f in ./*
do 
gzip -cdfq "$f" > "${f}".some_ext
done

This processes all files (even the uncompressed ones, via -f) and writes (via -c) the output to stdout using redirection to save the content of each file to its .some_ext counterpart. You could then remove the originals e.g. with bash

shopt extglob
rm -f ./!(*.some_ext)

or zsh

setopt extendedglob
rm -f ./^*some_ext

You could even save the resulting files to another dir (this time assuming you want to remove the original extension) e.g.

for f in *
do 
gzip -cdfq -- "$f" > /some/place/else/"${f%.*}".some_ext
done

and then remove everything in the current dir...

Post Undeleted by don_crissti
Post Deleted by don_crissti
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

You could do something like

for f in ./*
do 
gzip -cdfq "$f" > "${f}".some_ext
done

This processes all files (even the uncompressed ones, via -f) and writes (via -c) the output to stdout using redirection to save the content of each file to its .some_ext counterpart. You could then remove the originals e.g. with bash

shopt extglob
rm -f ./!(*.some_ext)

or zsh

setopt extendedglob
rm -f ./^*some_ext

You could even save the resulting files to another dir (this time assuming you want to remove the original extension) e.g.

for f in ./*
do 
gzip -cdfq "$f" > /some/place/else/"${f%.*}".some_ext
done

and then remove everything in the current dir...