How to execute command on list of file names in a file?

monu

I have listed the names of the files which are to be deleted into a file. How can I pass the file to rm command so that it should delete them one by one.

Jonas Berlin

If you have one file per line, one way to do it is:

tr '\n' '\0' < list_of_files_to_be_deleted.txt | xargs -0 -r rm --

The file list is given as input to the tr command which changes the file separator from linefeed to the null byte and the xargs command reads files separated by null bytes on input and launches the rm command with the files appended as arguments.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I sort a list of file names in the Windows command prompt?

From Dev

How to list file names on Windows as the Unix find command?

From Dev

How do I sort a list of file names in the Windows command prompt?

From Dev

How to use find command to list file names but not path?

From Dev

How to execute a command specific to a file?

From Dev

how to extract list of file names and created date of file with Dos (command prompt)

From Dev

How to DIRECTLY execute command in txt file in cmd?

From Dev

How to execute cmd command from text file?

From Dev

How to execute and save result of an OS command to a file

From Dev

How to execute a mongo command in sh file?

From Dev

How to execute a command whenever a file changes?

From Dev

How to execute source command from sh file

From Dev

Execute a command in a separate file

From Dev

How to direct to file folder and execute specific file using batch command

From Dev

How to convert and Execute lib_file.a Library file in Command prompt?

From Dev

How to loop over a file containing a list of directories and execute a command in each with python

From Dev

How to list only the file names in HDFS

From Dev

How to build a list of file names in a local directory?

From Dev

How to list all file names in terminal?

From Dev

How to list file names with a total of X letters

From Dev

Bat file list file names

From Dev

File Revision List File Names?

From Dev

Linux command to list the file names which have numbers?

From Dev

BASH: how would one execute rm on an array of file names?

From Dev

How to write a file list with foreign names to a csv file in the terminal?

From Dev

How to pass a list of file names to xargs after checking if the file exists?

From Dev

execute a command on a folder in the file system

From Dev

Execute a command where a file is found

From Dev

Find a file and execute a command in the file's directory

Related Related

  1. 1

    How do I sort a list of file names in the Windows command prompt?

  2. 2

    How to list file names on Windows as the Unix find command?

  3. 3

    How do I sort a list of file names in the Windows command prompt?

  4. 4

    How to use find command to list file names but not path?

  5. 5

    How to execute a command specific to a file?

  6. 6

    how to extract list of file names and created date of file with Dos (command prompt)

  7. 7

    How to DIRECTLY execute command in txt file in cmd?

  8. 8

    How to execute cmd command from text file?

  9. 9

    How to execute and save result of an OS command to a file

  10. 10

    How to execute a mongo command in sh file?

  11. 11

    How to execute a command whenever a file changes?

  12. 12

    How to execute source command from sh file

  13. 13

    Execute a command in a separate file

  14. 14

    How to direct to file folder and execute specific file using batch command

  15. 15

    How to convert and Execute lib_file.a Library file in Command prompt?

  16. 16

    How to loop over a file containing a list of directories and execute a command in each with python

  17. 17

    How to list only the file names in HDFS

  18. 18

    How to build a list of file names in a local directory?

  19. 19

    How to list all file names in terminal?

  20. 20

    How to list file names with a total of X letters

  21. 21

    Bat file list file names

  22. 22

    File Revision List File Names?

  23. 23

    Linux command to list the file names which have numbers?

  24. 24

    BASH: how would one execute rm on an array of file names?

  25. 25

    How to write a file list with foreign names to a csv file in the terminal?

  26. 26

    How to pass a list of file names to xargs after checking if the file exists?

  27. 27

    execute a command on a folder in the file system

  28. 28

    Execute a command where a file is found

  29. 29

    Find a file and execute a command in the file's directory

HotTag

Archive