1

I'm getting this error in a HP-UX machine

    + IFS=; 
    /home/machine1/folder/borrado_de_logs.sh[45]: read: A specified flag is not valid for this command.

And I'm using this code

    head -1 $rutatemporal/logfechas.log > $rutatemporal/cabecera.txt
    cabecera=`cat $rutatemporal/cabecera.txt`
    IFS=';' read -a arreglo<<EOF
    $cabecera
    EOF

In Hp-UX its seems that read -a is not allowed what argument I should use with read?

the content of cabecera.txt is this:

2019-02-01;/home/user/deletelogs/somelog.log

2 Answers2

3

It's probably because -a is not a POSIX compliant flag support for the read command. So it is not surprising that the default shell available in your HP-UX machine is not supporting it.

You can still use the read command without -a to split and store on individual variable names as below. Also you don't need a here-doc to read from the input file, but rather use the read command directly on the file itself

IFS=\; read -r date path < "$rutatemporal"/cabecera.txt
echo "$date"
echo "$path"
Inian
  • 80,270
  • 14
  • 142
  • 161
0

Type

$ help read

and you can see the available options and their meaning.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134