Updating data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Updating data
# 1  
Old 01-23-2010
Updating data

Hi Guys, i currently facing a problem with a script i'm writing.
I have a text file with the following data

Windows in 21 days:John Goodman:29.90:30:19

I will like to know what method i can use so in order to edit the data in any of the field with ":" being the delimiter.

example if i want to change the 4th field from 30 to 40, my data file will change to

Windows in 21 days:John Goodman:29.90:40:19

Thank you.
# 2  
Old 01-23-2010
Try:
Code:
awk -F: '{$4=40}1' OFS=: file

# 3  
Old 01-23-2010
Or
Code:
IFS=":"
read a b c d e f

# 4  
Old 01-23-2010
-or-
Code:
sed 's/:../:40/3' infile

# 5  
Old 01-24-2010
Quote:
Originally Posted by Franklin52
Try:
Code:
awk -F: '{$4=40}1' OFS=: file

hi i tried this and its work great but one problem is that i written such a function

Code:
echo -n "New Title:"
   read title
   awk -F: '{$1='"$title"'}1' OFS=: $Filename1 > $Filename2

It can only take in numbers and not a word or sentence
example if i key "Harry Potter", it can't capture the sentence and direct it to Filename2. However if i key numbers such as "40", everything works out fine.
Can i know how can i mod the code to take in strings also? Thank
# 6  
Old 01-24-2010
Try:
Code:
awk -F: '{$1='"\"$title\""'}1' OFS=: $Filename1 > $Filename2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with updating bios

I need to update a setting in the BIOS on our SCO Openserver 5.0.7 system and all I can bring up about it says I need to create a dos bootable disk of some sort. The problem is that it doesn't seem like dos is loading up fully. I created the dos bootable thumb drive on a Windows PC using Rufus... (7 Replies)
Discussion started by: hometrics
7 Replies

2. Ubuntu

16.04 not updating

Just installed the latest version on my hp stream, was tired of windows. Of the few times I've used Linux, this is the first time it won't update. Im connected to the net the updater recognizes that the OS needs 21 updates. But it won't download/install the updates. It also won't load the... (1 Reply)
Discussion started by: DabblingMadman
1 Replies

3. Shell Programming and Scripting

Run the Script from any stage by updating data from Oracle Table.

I have 100 Scripts, each containing 10-15 SQL's in them. Each Script run for 40 mins to 1 hour 30 mins. In the event of Failure in any step, if i re-start the Script, it will start running from the beginning. Which is waste of time. So in order handle this, i made the script to run from the... (7 Replies)
Discussion started by: kiran1992
7 Replies

4. Linux

How to Keep your core System and personal Data safe while updating to latest distro?

Hi everyone, Almost everything is in the title! Which partitions do you keep? Which partitions do you reformat, while doing a clean install? Personaly, I never format /var and /home partitions when I update to latest linux distribution. It has been working quite ok up to now, but I was... (3 Replies)
Discussion started by: freddie50
3 Replies

5. Programming

updating data in cvs file using c programming

hi every one i want to read and write data from cvs file using c program. but my problem is that at run time my data is increasing in both row wise and column wise. that means it is continuously updating in both direction. is there any way through which i can find the next colum or row for eg... (0 Replies)
Discussion started by: sajidtariq
0 Replies

6. Shell Programming and Scripting

updating LD_LIBRARY_PATH

Inside my csh script, I have the following command: source ${HOME}/.login When I execute my csh script, why do I get the following error message: /cygdrive/c/WINDOWS/system32/export: Permission denied This is what I have inside my .login #!/bin/bash export... (9 Replies)
Discussion started by: casau
9 Replies

7. Shell Programming and Scripting

Updating the data from one file to the other

Hi, Somebody please assist me in updating the data from one file to the other in Shell Scripting. There are two files file1 and file2. Both the files have differen data but a common attribute. e.g. JAVA_HOME. e.g. file1 has JAVA_HOME=/usr/j2se and file2 has... (3 Replies)
Discussion started by: Santosh251982
3 Replies

8. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

9. UNIX for Advanced & Expert Users

Updating entire column irrespective of any data in a file

Hi, I have a file A.txt (tab separated) as below: pavan chennai/tes/bangalore 100 sunil mangalore/abc/mumbai 230 kumar delhi/nba/andhra 310 I want to change only second column as below . Rest of columns as it is ;The ouput file is also tab... (4 Replies)
Discussion started by: kpavan2004
4 Replies

10. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies
Login or Register to Ask a Question