Updating a file in UNIX [message #119561] |
Fri, 13 May 2005 06:55  |
mrinalkumar01
Messages: 6 Registered: April 2005
|
Junior Member |
|
|
Hi,
I have a Pipe ("|") separated file in UNIX named Status, which contains month and status and which looks like
200501|E
200502|L
200503|U
200504|U
I want to update the second "|" separated field (Status) in one of the records.
Ex. I want to update the status of record of month 200503
I dont have access to any database on this server and i have to do this uing unix only.
Please let me know how to do this.
Thanks in Advance
|
|
|
Re: Updating a file in UNIX [message #119637 is a reply to message #119561] |
Fri, 13 May 2005 10:30   |
Frank Naude
Messages: 4593 Registered: April 1998
|
Senior Member |
|
|
Try something like this:
#!/bin/ksh
IFS="|"
cat input | while read month status
do
if [ "$month" == "200503" ]; then
status=X
fi
echo "$month|$status" >>output
done
Best regards.
Frank
|
|
|
|