June 21, 2018

Undo an untar in the wrong place

tar tfz filename.tar.gz | xargs rm

  • October 19, 1999
  • By James Andrews
This command is useful to delete the effects of accidental untarring into the wrong directory.

It works by passing the list of filenames from the stdout of the tar command into xargs, which in turn runs rm with the list of files as arguments. You could, of course, use it to run any command on all the filenames in a tar ball.

Most Popular LinuxPlanet Stories

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.