How Do You Print out Lines of a File One-by-One with No Commas and No Semicolons from a Linux Shell?

Problem scenario
You have a flat file that may have lines that terminate (or end) with semicolons or commas. You want to print one line of this file at a time without commas or semicolons. How do you do this with Linux?

You have a file named "list" (with no extension) in the same directory as this script below.

Run this Bash script:

while read list; do
   var1=$(echo $list | sed 's/,//g') # remove the comma if any
   var1=$(echo $var1 | sed 's/;//g')
   echo $var1
 done <list

Leave a comment

Your email address will not be published. Required fields are marked *