Edit date entry inside a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Edit date entry inside a file
# 1  
Old 07-16-2010
Edit date entry inside a file

Hi All,

I wanted to edit the date value located at /var/opt/CPsuite-R65/fw1/conf/local.scv. The date entry looks like this :

:Signature (">=20100717")

How can I update the date value by 1 day every other day while preserving the margins of the whole file in a shell script? I have attached a portion of the file containing the date entry.

Thanks in advance for your help.
# 2  
Old 07-16-2010
Code:
DATE=$(date +%Y%m%d)
sed '/Signature/s/=[0-9]*/='$DATE/ local.scv > new.scv
# (Look at new.scv to make sure it's what you want)
mv new.scv local.scv

# 3  
Old 07-17-2010
Quote:
Originally Posted by KenJackson
Code:
DATE=$(date +%Y%m%d)
sed '/Signature/s/=[0-9]*/='$DATE/ local.scv > new.scv
# (Look at new.scv to make sure it's what you want)
mv new.scv local.scv

Code:
sed '/Signature/s/=[0-9]\{8\}/='$DATE/  local.scv  > new.scv

# 4  
Old 07-19-2010
Bug

Thanks guys for your response. This works. Smilie
# 5  
Old 07-20-2010
need help on editing the DATE value to one week ago. How can I do that on #!/bin/sh? Thanks again for any response.
# 6  
Old 07-20-2010
Hi,
Code:
date --d '1 week ago' +%Y%m%d

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching a file inside a .tar.gz file by date

Hi, I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date? Thanks! (4 Replies)
Discussion started by: erin00
4 Replies

2. Shell Programming and Scripting

How to find the Missing date inside the FILE?

Hi am using Unix AIX Ksh have a FILE CAT FILE 08/02/2013 16/02/2013 18/02/2013 I need the Outputs as Missing date are 09/02/2013 to 15/02/2013,17/02/2013 can anyone help me !!! (1 Reply)
Discussion started by: Venkatesh1
1 Replies

3. Shell Programming and Scripting

Searching for unknown date inside the file and replace to new date

Hello, Iam a newbies to Shell scripting. Iam trying to replace the date inside the file to new date. is there anyway that we can just use the pattern to search as "..." I have many files want to replace with the same date, and each file contains different date. Thanks for your help. ... (2 Replies)
Discussion started by: Daro
2 Replies

4. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

5. Shell Programming and Scripting

How to edit file to have one line entry?

Hello All, My file content is: DROP TABLE "FACT_WORLD"; CREATE TABLE "FACT_WORLD" ( "AR_ID" INTEGER NOT NULL, "ORG_ID" INTEGER NOT NULL ) DATA CAPTURE NONE COMPRESS YES; I want to change this file to have entries in one... (6 Replies)
Discussion started by: akash2508
6 Replies

6. Shell Programming and Scripting

convert date inside a file

Hi guys I've got a file with this line inside. 200,2010,318,1000,4.377,70.9,.835,.592,.243,-.438,0,881 The line always begins with number 100 or number 200, follow the year, the day in the year, the hour, and other stuff Here, the important fields are, 2, 3 and 4. -Filed 2 --> year... (4 Replies)
Discussion started by: iga3725
4 Replies

7. Shell Programming and Scripting

how to insert the entry inside the line

Hi I have a file which contains entry similar to this one: PX_LIST="2259 2215 270 2635 2874 2713 243 4124 2529 2874 34 477 " Is there a efficient(short) way to use "awk" or "sed" to enter any number, lets say 7777, as the first number inside the quotes, so the result would look like this:... (3 Replies)
Discussion started by: aoussenko
3 Replies

8. Shell Programming and Scripting

shell script to edit file and delete entry

Can anyone provide me a shell script to edit a xml file and delete one entry. To do manually i can edit(vi editor) the file and 'dd' will delete the file.But I wiluld to know if I can do with a script. Thanks in advance Tannu (6 Replies)
Discussion started by: tannu
6 Replies

9. Shell Programming and Scripting

Edit entry if not equal

Ok here's the scenario, i have a ll.conf file and masterlist. #cat ll.conf 123456 banner 1234 abcdefghi #cat masterlist abcdefghi banner 123456789 what script to change ll.conf banner 123456789 from banner 1234 if they are not equal. the final output will looks like this. #cat... (4 Replies)
Discussion started by: kenshinhimura
4 Replies

10. UNIX and Linux Applications

Edit/update an /etc/group database entry (c/c++)

Hello I'm writing a program for managing accounts and groups in a linux system. My problem is how to update the members of a group in the /etc/group file,if i have to add/remove those members. total 3 variables for adding some new members to the group : char **oldmembers=grp->gr_mem; ... (1 Reply)
Discussion started by: mekos
1 Replies
Login or Register to Ask a Question