user3633745
user3633745

Reputation: 11

Deleting specific symbols inside file

I have a problem. I have a file in this format:

Hi / Tom /
Be / Nice /
...

And I need to delete "/" and " "(space) and sort it

Be Nice
Hi Tom
...

Upvotes: 0

Views: 3727

Answers (2)

Rahul
Rahul

Reputation: 77876

you can use tr command like

cat inputfile.txt | tr -s "\/" "" | tr " " "\n" | sort | tr "\n" " "

Upvotes: 1

user1641854
user1641854

Reputation:

for sorted_word in $(for word in $(sed  -e 's/\/ //g' path_to_file); do printf "%s\n" ${word}; done | sort); do printf "%s " ${sorted_word}; done ; printf "%s\n"

Upvotes: 1

Related Questions