-2

I read a record from a file which contains the following value :

    1907;1193;2317;COMMENT;TAG: *** REASON : Circumvention *** SSC 

I want to split up this record into several variables :

       rowId=$(echo $record | cut -d ';' -f1)
       columnId=$(echo $record | cut -d ';' -f3) 
       columnName=$(echo $record | cut -d ';' -f4) 
       dataValue=$(echo $record | cut -d ';' -f5) 

The first 3 variables contains the right values but the variable "dataValue" contains :

    TAG: testfile.txt test.sh tst.sh REASON : Circumvention compareTxtFiles.sh testfile.txt test.sh tst.sh SSC 

In other words the system changed the "***" into the files residing on my home-directory. How can I avoid this and keep the text as it should be ?

Digvijay S
  • 2,665
  • 1
  • 9
  • 21
Bjorn
  • 21
  • 1
  • 3
    See [When to wrap quotes around a shell variable?](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) – oguz ismail Jul 24 '20 at 13:16

1 Answers1

0

Try this:

record="1907;1193;2317;COMMENT;TAG: *** REASON : Circumvention *** SSC"
dataValue=$(echo "$record" | cut -d ';' -f5)
echo "$dataValue"
Vijay
  • 778
  • 4
  • 9