Sponsored Content
Full Discussion: sed commands
Top Forums Shell Programming and Scripting sed commands Post 55344 by dbrundrett on Thursday 9th of September 2004 11:41:52 AM
Old 09-09-2004
sed commands

I have a configuration file that when a certain script runs in updates. I want to use sed and can't seem to get the syntax right.

A line from the configuration file looks like:
DATE=20040909 12:00:10

When the script is run I want to change the date and time, i.e. removing the previous parameter of 20040909 12:00:10, but keeping the DATE= part.

Can variables be added into the sed command?
How would the sed command be constructed to do the above?

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multiple sed commands

hello! I have a few sed commands sed '/^$/d' < $1 > tmp.t sed '/^ \{3,\}/d' < tmp.t > tmp1.txt ..... how can I write them in a single line? sed '/^$/d' < $1 > | '/^ \{3,\}/d' < $1 > tmp1.txt any idea? thanks. (5 Replies)
Discussion started by: george_
5 Replies

2. UNIX for Dummies Questions & Answers

combining sed commands

I would like to change the lines: originalline1 originalline2 to: originalline1new originalline1newline originalline2new originalline2newline To do this, id like to combine the commands: sed 's/^/&new/g' file > newfile1 and sed '/^/ a\\ newline\\ \\ (2 Replies)
Discussion started by: Dave724001
2 Replies

3. Shell Programming and Scripting

Using variables in sed commands

Hi there, I need to be able to put the hostid of my box into a file (replacing the text "enter_hostid_here" so i tried sed -e 's/enter_hostid_here/`hostid`/g' inputfile > outputfile but it takes the `hostid` literally as text .....how can I get this info into the file (ideally in a single... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

4. Shell Programming and Scripting

Using variables within awk/sed commands

Can I use my own variables within awk and sed for example: I've written a while loop with a counter $i and I want to use the value of $i within sed and awk to edit certain lines of text within a data file. I want to use : sed '1s/$/texthere/g' data.csv Like this: sed '$is/$/$age/g' data.csv... (5 Replies)
Discussion started by: mustaine85
5 Replies

5. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

6. Shell Programming and Scripting

merging sed commands

Hi, I've a shell that uses two sed commands to tailor a file. sed 's/ */ /g' | sed 's/%/%%/g' Is it possible to merge this in to a single sed? Thanks! (2 Replies)
Discussion started by: dvah
2 Replies

7. Shell Programming and Scripting

Using commands inside sed substitution

Dear Friends, Please let me know how to use the date command inside the substitution flag replacement string. echo "01 Jan 2003:11:00:06 +0100" | sed 's/\(.*\)/`date -d \1 "+%Y%m%d%H%M%S"`/' I want to supply \1 string to Here mention below as part of replacement string, date -d <Here>... (5 Replies)
Discussion started by: tamil.pamaran
5 Replies

8. Shell Programming and Scripting

Grouping sed commands

Hello, would you please help me with why my SED command file is outputting the entire input file instead of only the text that I'm trying to block? cat testfile O 111111111-00 DUE-DATE METHOD: FREQUENCY: O 222222222-00 DUE-DATE METHOD: FREQUENCY: O 333333333-02 DUE-DATE METHOD:... (4 Replies)
Discussion started by: lneedh1
4 Replies

9. Shell Programming and Scripting

Nested sed commands

Hi, I get the following response by gphoto2 and I would like to substract the index number of the current item. In this case 3. gphoto2 --get-config /main/imgsettings/iso Label: ISO Speed Type: RADIO Current: 200 Choice: 0 100 Choice: 1 125 Choice: 2 160 Choice: 3 200 Choice: 4 250 ..... (11 Replies)
Discussion started by: Nic2015
11 Replies

10. Shell Programming and Scripting

Looking for sed commands to add some strings

Hi All, I have one file which has contents as following. I have now to add some strings into this file. In below there is a "Description" field, and I have to look line by line and as the description contents will be finished, I have to add the string "Hello world" followed by a TAB. So before... (2 Replies)
Discussion started by: wridler
2 Replies
rc.config(4)						     Kernel Interfaces Manual						      rc.config(4)

NAME
rc.config, rc.config.d - files containing system configuration information SYNOPSIS
DESCRIPTION
The system configuration used at startup is contained in files within the directory The file sources all of the files within and and exports their contents to the environment. /etc/rc.config The file is a script that sources all of the scripts, and also sources To read the configuration definitions, only this file need be sourced. This file is sourced by whenever it is run, such as when the command is run to transition between run states. Each file that exists in is sourced, without regard to which startup scripts are to be executed. /etc/rc.config.d The configuration information is structured as a directory of files, rather than as a single file containing the same information. This allows developers to create and manage their own configuration files here, without the complications of shared ownership and access of a common file. /etc/rc.config.d/* Files This is where files containing configuration variable assignments are located. Configuration scripts must be written to be read by the POSIX shell, and not the Bourne shell, or In some cases, these files must also be read and possibly modified by control scripts or the sam program. See sd(4) and sam(1M). For this reason, each variable definition must appear on a separate line, with the syntax: No trailing comments may appear on a variable definition line. Comment statements must be on separate lines, with the comment character in column one. This example shows the required syntax for configuration files: Configuration variables may be declared as array parameters when describing multiple instances of the variable configuration. For example, a system may contain two network interfaces, each having a unique IP address and subnet mask (see ifconfig(1M)). An example of such a dec- laration is as follows: Note that there must be no requirements on the order of the files sourced. This means configuration files must not refer to variables defined in other configuration files, since there is no guarantee that the variable being referenced is currently defined. There is no protection against environment variable namespace collision in these configuration files. Programmers must take care to avoid such prob- lems. /etc/TIMEZONE The file contains the definition of the environment variable. This file is required by POSIX. It is sourced by at the same time the files are sourced. SEE ALSO
rc(1M). rc.config(4)
All times are GMT -4. The time now is 10:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy