Home > Archive > AWK > August 2007 > Shell Script Required.......
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Shell Script Required.......
|
|
|
| Hi All,
I have just entered into the shell script world. And I have required a
script which will do the following:
I have one data file which is having data of following type:
aa1,bb1,cc1,dd1
aa2,bb2,cc2,dd2
aa3,bb3,cc3,dd3
and so on....
now what i want to chage the value of column 2 and 4 to some other
value for all the rows...
i.e. now the output data file should be:
aa1,12,cc1,34
aa2,12,cc2,34
aa3,12,cc3,34
and so on....
Please provide me the script for this...i know we want to use awk for
this...but i have never used it...
And it is very urgent for me.....
Please let me know if somebody required further information....
Thanks in advance.....
| |
| Ed Morton 2007-08-23, 6:57 pm |
| monty wrote:
> Hi All,
>
> I have just entered into the shell script world. And I have required a
> script which will do the following:
>
> I have one data file which is having data of following type:
>
> aa1,bb1,cc1,dd1
> aa2,bb2,cc2,dd2
> aa3,bb3,cc3,dd3
>
> and so on....
> now what i want to chage the value of column 2 and 4 to some other
> value for all the rows...
> i.e. now the output data file should be:
>
> aa1,12,cc1,34
> aa2,12,cc2,34
> aa3,12,cc3,34
>
> and so on....
>
> Please provide me the script for this...i know we want to use awk for
> this...but i have never used it...
> And it is very urgent for me.....
>
> Please let me know if somebody required further information....
>
> Thanks in advance.....
>
awk 'BEGIN{FS=OFS=","}{$2=12;$4=34}' file
This was an awk question. If you REALLY have a shell question, post it
to comp.unix.shell.
Ed.
| |
| Radoulov, Dimitre 2007-08-23, 6:57 pm |
| monty wrote:
[...]
> I have one data file which is having data of following type:
>
> aa1,bb1,cc1,dd1
> aa2,bb2,cc2,dd2
> aa3,bb3,cc3,dd3
>
> and so on....
> now what i want to chage the value of column 2 and 4 to some other
> value for all the rows...
> i.e. now the output data file should be:
>
> aa1,12,cc1,34
> aa2,12,cc2,34
> aa3,12,cc3,34
>
> and so on....
[...]
awk '{$2=12;$4=34}1' FS="," infile
Use nawk on Solaris.
Dimitre
| |
| Radoulov, Dimitre 2007-08-23, 6:57 pm |
| Radoulov, Dimitre wrote:
> monty wrote:
> [...]
>
> Use nawk on Solaris.ta file should be:
> [...]
>
> awk '{$2=12;$4=34}1' FS="," infile
Sorry:
awk '{$2=12;$4=34}1' FS="," OFS="," infile
Dimitre
| |
| Kenny McCormack 2007-08-23, 6:57 pm |
| In article <46cd8870$0$90273$14726298@news.sunsite.dk>,
Radoulov, Dimitre <cichomitiko@gmail.com> wrote:
....
>Use nawk on Solaris.
ITYM:
Use gawk everywhere (*).
(*) Unless TAWK is available on your platform.
|
|
|
|
|