Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1104161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:26:44+00:00 2026-05-17T01:26:44+00:00

I am trying to make a shell script to remove special characters, like {}()!,’

  • 0

I am trying to make a shell script to remove special characters, like {}()!,’ etc. So far I have referenced a past question I asked here, however I get a strange error message:

-bash-3.2$ ./test2.sh
./test2.sh: line 7: unexpected EOF while looking for matching `"'
./test2.sh: line 10: syntax error: unexpected end of file

test2.sh

#!/bin/bash
shopt -s nullglob
for file in *
do
        if [ -f "$file" ]; then
        newfile="`echo $file | tr -d '[{}(),\!]' | tr -d "\'" | sed 's/_-_/_/g'`"
        mv "$file" "$newfile"
        fi
done

Not sure where I am going wrong on this one, the files are named like:

Folder - 01
Folder 02!
Folder(03)
Folder Four_Three

The desired output would be

Folder 01
Folder 02
Folder 03
Folder Four Three

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:26:44+00:00Added an answer on May 17, 2026 at 1:26 am
    shopt -s extglob
    shopt -s nullglob
    for i in *; do echo "mv $i ${i//[[:punct:]]/}"; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to make some small shell-like utility for a custom script I
I am trying to make an interactive shell script in Perl. The only user
I'm trying to write a shell script that will make several targets into several
I am trying to make a shell script that takes arguments and then performs
I am trying to make a new command which runs a shell script that
Hey, I started bash shell scripting and I'm trying to make a script for
I am Currently trying to make a shell script that will email me and
I am trying to make a very simple shell script that frees up some
I am trying to make heads or tails of a shell script. Could someone
I am trying to make a shell script that creates a mysql dump and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.