Visit Our UNIX and Linux User Community

update problem

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting update problem
# 1  
Old 10-07-2007
update problem

Hello Friends, I am completely new to unix. Joined forum today. I have a problem which may seem very simple to you all. I will really appreciate your help. Smilie

I have a file.

Purpose: to update this file as new product comes in. (product means: acer,intel, amd, etc..)

CASE 1: New Product: acer,41,Q-8033762700,ok
(you can consider this 4 fields seperated by comma as input arguments)
i.e. we have new product (acer41 instead 40) as below, then we need to add new line

output file should look like

CASE 2: New Product: dell,22,Q-8098763501,ok
i.e. we have same product (dell 22 but Q change from Q-8098763500 to Q-8098763501) as below,then we need to replace that line

output file should look like

Brief: This 2 case should keep working. lines will keep getting added when new product is there. & if same product & Q change then line will be replaced.

I will be really thankful if someone helps as soon as poss. Smilie
# 2  
Old 10-07-2007
Without any validation or error handling:

echo "dell,22,Q-8098763501,ok" >> file
echo "acer,41,Q-8033762700,ok" >> file
awk -F, '{arr[$1$2] = $0} END { for (i in arr) { print arr[i] }}' file > newfile
mv newfile file

# 3  
Old 10-08-2007

Thank you very much admin. Perfect solution. Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #920
Difficulty: Medium
The Unix time number is zero at the Unix epoch, and increases by exactly 86400 per day since the epoch.
True or False?

9 More Discussions You Might Find Interesting

1. Solaris

How to update Solaris 10 Update 3 to Update 11?

Hi friends, We have a Solaris machine running 10 update 3 -bash-3.2# cat /etc/release Solaris 10 11/06 s10s_u3wos_10 SPARC Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. ... (6 Replies)
Discussion started by: prvnrk
6 Replies

2. Shell Programming and Scripting

Problem with GREP + CUT - script for automatic update of STEAM GAME AR

Hello, I have a problem with the /etc/rc.d/init.d script to automatically update STEAM GAME ARK. I've converted 3 scripts into one, but something does not work correctly ... The problem is in the file latestavailableupdate.txt / line 36/39. It think the problem is with script, it wrongly... (2 Replies)
Discussion started by: kshishu
2 Replies

3. Red Hat

RedHat 5 update 9 BASH update issue

Hi i want to update the BASH because of the "shell shock" vulnerability. my RedHat 5 is clean install with the default mirror site. when im running the command: yum update bash im getting a message saying there is no update. you can see in the attach picture... what am i doing wrong? is... (4 Replies)
Discussion started by: guy3145
4 Replies

4. UNIX for Dummies Questions & Answers

Problem with update noip

Hi i have server debian no ip is not updated, I'm looking for a script executed the command every 2 minite noip2 (5 Replies)
Discussion started by: azzeddine2005
5 Replies

5. Programming

MYSQL - trigger update on record insert or update

Right I have a MYSQL database with table1 with 3 columns, colA, colB and colC. I want to combine the data in the 3 columns into a 4th column names col_comb. Here's the SQL command that works: UPDATE table1 SET `col_comb` = CONCAT( `colA` , ' - ', `colB` , ', ', `colC` ); So now I want this... (5 Replies)
Discussion started by: barrydocks
5 Replies

6. Solaris

Is it possible to "upgrade" Sol10 update 9 to update 10?

Is it possible to "upgrade" Sol10 update 9 to update 10 by booting from the DVD? I had never even tried this until a user asked me to do it, so i tried and it just hung there after the part where it reads the rules.ok file. Is this even possible to upgrade? or does it have to be a new install. ... (5 Replies)
Discussion started by: BG_JrAdmin
5 Replies

7. Solaris

Install update 6 on solaris with update 3

I want to update my solaris 10 server which is currently on update 3 stage. A new application require it to be on update 6. What is the best way to make it update 6. should i just install the patch or should i go for the liveupgrade?? thanks for you help in advance (3 Replies)
Discussion started by: uxravi
3 Replies

8. Linux

Deploying Qt on CentOS - update problem

I am developing a simple client-server (TCP) application using QT. The server side is to run on CentOS. I am developing both the server and client programs using Ubuntu. I am now attempting to deploy an experimental version of the server application on the CentOS server, but I am not yet... (2 Replies)
Discussion started by: David Brown
2 Replies

9. Solaris

Problem with S10 Update Manager

Hi, The green shield at the bottom right of the screen says 'Updates Available', so I click on it to get the latest updates. Then I select the first update in the list by clicking the checkbox and then clicking 'Install Update'. After a few seconds of trying to install the update an error... (1 Reply)
Discussion started by: patcom
1 Replies

Featured Tech Videos