I have input(output.txt with almost 2000lines) like
lorem ipsum lorem ipsum ["a","b","c","d"] lorem ipsum lorem ipsum ["e","f","g","h"]
My output1.txt should be
a b c d e f g h
First, i am trying to put all values inside [] in one file. But ultimately my aim is to achieve output1.txt. It would be great if someone help me to achieve in one shot(extracting data inside [] and removing "" and comma and place values in each line)
My code is as of now
reg="\[([^]]+)\]"
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line = ~$reg ]] ; then echo "$line" >> home/hdpsrvc/sandeep/hbase/output1.txt ; fi
done < /home/hdpsrvc/sandeep/hbase/output.txt
File is not created in specified path and also on the terminal there is no error. I followed following stackoverflow links to write above code
shell script. how to extract string using regular expressions Regular expression to extract text between square brackets