How do I remove a character from a string in a Unix shell script?

Generalkidd

I have several files that are named like this: file - name.txt

How do I remove the " - " using a bash script in UNIX from all the files?

kojiro

Use parameter expansion to remove the part of the string you want to be rid of. Make sure to use double-quotes to prevent mv from misinterpreting input.

for i in ./*' - '*; do
    mv "$i" "${i// - }"
done

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 remove a character from a string in a Unix shell script?

From Dev

How do I remove a character from a list or string in Erlang?

From Dev

How do I remove part of a string from a specific character?

From Dev

How do I remove a character once from a string [python]?

From Dev

How do I remove a character from a string in c++?

From Dev

How do I add time to a date in unix shell script?

From Dev

How to cut a space from a string in a Unix shell script

From Dev

How to cut a space from a string in a Unix shell script

From Dev

How to remove frontend spaces | Unix shell script |

From Dev

How to replace string in unix shell script

From Dev

Regex: How do I remove the character BEFORE the matched string?

From Dev

How to remove a character from a string

From Dev

How do I save a string of numbers from an ongoing command to a list in a shell script?

From Dev

How do I remove CSS from a string?

From Dev

How Do I Remove A Vowel From String

From Dev

How do i remove chars from a string?

From Dev

How do I remove punctuaution from a string

From Dev

how do i remove a letter from string

From Dev

How can I remove the special character words from a string?

From Dev

How to cut a specific character in a file in unix shell script

From Dev

How to escape a special character that is hidden inside variable in unix shell script

From Dev

How do i remove a part of my string and append it at the back (shell)

From Dev

How do I remove a character from a column of data in Excel

From Dev

How do I remove this character from my regex?

From Dev

In an expect script, how do I remove a set of special characters from a string variable?

From Dev

How can I remove a character from a string while doing character by character processing?

From Dev

How do I execute a string as a shell script in C++?

From Dev

How do I execute a string as a shell script in C++?

From Dev

Unix Shell Script: Remove duplicates from line ignore blank lines

Related Related

  1. 1

    How do I remove a character from a string in a Unix shell script?

  2. 2

    How do I remove a character from a list or string in Erlang?

  3. 3

    How do I remove part of a string from a specific character?

  4. 4

    How do I remove a character once from a string [python]?

  5. 5

    How do I remove a character from a string in c++?

  6. 6

    How do I add time to a date in unix shell script?

  7. 7

    How to cut a space from a string in a Unix shell script

  8. 8

    How to cut a space from a string in a Unix shell script

  9. 9

    How to remove frontend spaces | Unix shell script |

  10. 10

    How to replace string in unix shell script

  11. 11

    Regex: How do I remove the character BEFORE the matched string?

  12. 12

    How to remove a character from a string

  13. 13

    How do I save a string of numbers from an ongoing command to a list in a shell script?

  14. 14

    How do I remove CSS from a string?

  15. 15

    How Do I Remove A Vowel From String

  16. 16

    How do i remove chars from a string?

  17. 17

    How do I remove punctuaution from a string

  18. 18

    how do i remove a letter from string

  19. 19

    How can I remove the special character words from a string?

  20. 20

    How to cut a specific character in a file in unix shell script

  21. 21

    How to escape a special character that is hidden inside variable in unix shell script

  22. 22

    How do i remove a part of my string and append it at the back (shell)

  23. 23

    How do I remove a character from a column of data in Excel

  24. 24

    How do I remove this character from my regex?

  25. 25

    In an expect script, how do I remove a set of special characters from a string variable?

  26. 26

    How can I remove a character from a string while doing character by character processing?

  27. 27

    How do I execute a string as a shell script in C++?

  28. 28

    How do I execute a string as a shell script in C++?

  29. 29

    Unix Shell Script: Remove duplicates from line ignore blank lines

HotTag

Archive