i have a file .dat with this format
#id|firstName|lastName|gender|birthday|creationDate|locationIP|browserUsed
933|Mahinda|Perera|male|1989-12-03|2010-03-17T13:32:10.447+0000|192.248.2.123|Firefox
1129|Carmen|Lepland|female|1984-02-18|2010-02-28T04:39:58.781+0000|81.25.252.111|Internet Explorer
and i want to replace a column (number of column is given from user with the command ./tool.sh -f <file> --edit <id> <column> <value>) with the value (value is given from user with the same command) i cannot insert <column> parameter inside awk
#!/bin/bash
if [ "$1"="-f" ] ; then
if [ "$3"="--edit" ] ; then
y=$6
x="$"$5
awk -F '|' ' '$4'==$1{$x-=$y;print }' <$2
fi
fi
i want something like this when user give this command
./file.sh -f file --edit 933 3 spyros
(the 3rd field than before has the value "Perera" change to "spyros)
933|Mahinda|spyros|male|1989-12-03|2010-03-17T13:32:10.447+0000|192.248.2.123|Firefox
-=in there at all given your description. Edit your question to provide a better explanation, an example of the operation you want to perform, and the expecte output given your posted sample input../tool.sh -f --edit, but that makes--editinto$2, yet you test for it in$3. It looks as if you redirect from$2, so presumably you mean./tool.sh -f filename --edit …, but it isn't wholly clear what you expect in arguments 4, 5 and 6. You should probably use-vto convey values toawkfrom the shell.