answersLogoWhite

0


Best Answer

You have mentioned "Shell Script", I assume you are working on Linux/Unix/Mac OS X environment.

I would suggest to use small utility which by default should be included in almost all above mentioned OS families. It is called sed (stream editor).

Here is how to use the utility:

sed -e 's/#//g' source_file.txt > destination_file.txt

What it does it changes all '#' to '' (removes it).

's///g':

* s - substitute * - standard regular expression * - symbol that will be as replacement. * g - global Here is a Bash Script: #!bin/bash

# Checking parameters number, we need two

if [ $# -ne 2 ]

then

echo "Wrong number of parameters, please try again."

exit 1

fi

# Checking to see if file actuall exists and it is readbale

if [ -e $1 -a -s $1 ]

then

# Calling sed program to find all '#' character and replace them with '' (empty),

# redirecting stdout (standard output stream) to file (second argument)

sed -e 's/#//g' $1 > $2

echo "Job done, please check " $2 " file."

else

echo "Missing file, please try again."

exit 2

fi

exit 0

First parameter of script should be input file and second one - output file.

Source File:

Word # Word

Word #

# Word

Destination File:

Word Word

Word

Word

To change more than one character you could use this regular expression:

s/[Word]/A/g

Same source file and destination would look like:

AAAA # AAAA

AAAA #

# AAAA

[All possible chars]; [Word] = { 'W' OR 'o' OR 'r' OR 'd' }

There are utilities like tr, that could be used for the same purpose.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

See related link.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a shell script to read a text file delete the special symbols in it and save the file with a new file name?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write about cuneiform script?

The Sumerians were the first to devise a script. This is knew as the cuneiform script. This in the from of pictographs signs, symbols and pictures which denoted objects. Henry Rawlinson deciphered the Sumerian script......


What does mean in theatre script symbols?

Write the name of the symbol out in the question; you may be trying to use a character in the question that the system does not allow.


How do you you write a script?

You write a script by writing there name then writing what they say simple


Should Kids Have To Write In Script?

yea i think kids could write and script.... i think its cool my friends like to write in script lolz


What does The Script mean?

The prefix script- means to write.


What does the prefix script mean?

The prefix script- means to write.


How do you write an awk script to delete duplicated line from a text file The order of the original lines must remain unchanged?

Hard to answer - you don't say where the duplicated line might be.


How can you make a script?

Write it.


What to do after you write a script?

Make a play


What is the root word of write?

script


What is the root of script?

The root of the word "script" comes from the Latin word "scribere," which means "to write." This Latin root reflects the original meaning of script as something written down.


What is the name of script used to write Telugu?

It is called Telugu script. Telugu script evolved from Brahmi script around 2500 years ago.