Sponsored Content
Full Discussion: Problem with for loop/sed ?
Top Forums Shell Programming and Scripting Problem with for loop/sed ? Post 302086719 by chiru_h on Saturday 26th of August 2006 07:56:42 PM
Old 08-26-2006
Problem with for loop/sed ?

I have a hostnames file which has:
$ cat hostnames.txt
serverxx1
serverxx2
serverxx3

My script:
#!/bin/sh
fileA=build.xml
for i in ./hostnames.txt ; do
sed 's/createConfig machine="Machine"/createConfig machine=" '$i' "/g' "$fileA" > ./tmpfile
done

FileA has:
createConfig machine="Machine"

Output should have FileA:
createConfig machine="serverxx1"
createConfig machine="serverxx2"
createConfig machine="serverxx3"

But I am getting error as
sed: -e expression #1, char 58: Unknown option to `s'

If I change '$i' to just $i , it's replacing Machine with $i not it's value.

Can somebody please help me - if I am using the sed/for properly?

Thankyou
chiru_h
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed in a for loop

dear guys, I want to replace the beginning of some lines in a file by (,) The sequence number of lines is located in a file named numbers so, i used this simple script to do so, but it didn't work. it does'nt recognize the $j in the command sed #! /bin/sh for j in `cat numbers` do sed '$j... (6 Replies)
Discussion started by: marwan
6 Replies

2. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

3. Shell Programming and Scripting

For loop with sed

Hi there, I have 1 file with different 144 lines and 144 files that I want to change with a sed. What I want to do is to go trough the file with the 144 different lines take the line a replace a certain pattern with said in the first file of the folder where the 144 files are. Take the second... (3 Replies)
Discussion started by: sickboy
3 Replies

4. Shell Programming and Scripting

Using sed in for loop

I have a file MAT.txt which contains the following data: mat1.txt mat2.txt . . . . mat100.txt I want to remove the '.txt' from every line and have an output file with the following data: mat1 mat2 . . . . mat100 I know this can be done with sed easily for each line, but I do... (8 Replies)
Discussion started by: ursaan
8 Replies

5. Shell Programming and Scripting

For Loop and assigning Value using Sed

Hi, Please help me writing for loop to fetch data and store in variable from a text file which contains data as below: 12 46 56 5466 111 There are 40 lines of data...!!!! I jus need all data from line no 4 to 40 ie data for 4,6,8......40. (2 Replies)
Discussion started by: fidelis
2 Replies

6. UNIX for Dummies Questions & Answers

grep sed and a loop

:wall: I have a requirement to search a log file that never rotates for certain values. If I find them I pipe them to a another file. To log file is constanyl being appened with new lines and never rotating Easy so far. The problem is I dont want to pipe out matches already seen before. ... (3 Replies)
Discussion started by: gunnahafta
3 Replies

7. UNIX for Dummies Questions & Answers

Using sed in a for loop

Hello I have a group of files a1.profile a2.profile a3.profile a4.profile b1.profile b2.profile b3.profile b4.profile These files all have the same first line with a value s1 atop the columns s1_context s1_ref s1_sample s1_% etc I am trying to use sed in a for loop to replace the s1 in the... (2 Replies)
Discussion started by: plumb_r
2 Replies

8. UNIX for Dummies Questions & Answers

Using sed in a for loop

Hi, I have a file called 1.txt, I want to create 2.txt through 100.txt using a for loop. In each instance of the loop, I want to change all "1"'s in the text file to "2"s and so on... I tried the code below to do this: for i in {2..100}; do sed 's/1/$i/g' 1.txt > $i.txt; done but it... (1 Reply)
Discussion started by: evelibertine
1 Replies

9. Shell Programming and Scripting

Problem with loop within loop

Hi, I work on Ab-initio ETL tool which is based on Unix. I made a small script which has two loop's one with in another. All the functionality is working for the first line of outer loop but when it comes to other lines of outer loop it is throwing error as command not found. Below is the... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

10. UNIX for Beginners Questions & Answers

Problem with sed in for loop, would appreciate some help

Dear expert users, I am having trouble with this for loop, where I am editing a design file, replacing the subject, session and another parameter in the template design file. When implementing the for loop, it did not do what I wanted it to, for example editing to {2014}/CAT_Run0 instead of... (3 Replies)
Discussion started by: andrevol
3 Replies
config(8)						      System Manager's Manual							 config(8)

NAME
config - Builds system configuration files SYNOPSIS
/sys/conf/config [-k] [-p] [-q] system_name FLAGS
Creates a define variable 'KDEBUG' that can be used to conditionally compile source code for kernel debugging. Configure the system for profiling. You must have sources to use this flag. Concatenates and displays all the system configuration files, including any configura- tion files described in the /sys/conf/NAME.list file. DESCRIPTION
The doconfig command calls the config command to build a set of system configuration files from a file that describes the sort of system that is being configured. The config command also takes as input another file that tells it what files are needed to generate a system. This other file can be augmented by a configuration-specific set of files that name alternate files for a specific machine. Normally, you should run the doconfig program and not the config command. If you need to issue the config command, be sure to change your directory to the /sys/conf directory. As an argument to the config command, specify the name of a system configuration file containing device specifications, configuration options and other system parameters for that specific system configuration. The config command places all its output files in the directory The output of config consists of a number of files; each machine type has its own specific set of files. All machine types have a makefile which is used by make during the system build. Typically, there are also a set of header files which contain definitions of the number of various devices that will be compiled into the system, and a set of swap configuration files contain definitions for the disk areas to be used for swapping, the root file system, argument processing, and system dumps. After running config, you run make depend in the directory where the new makefile was created. If any other error messages are produced by config, the problems in the configuration file should be corrected and config should be run again. Attempts to compile a system that had configuration errors are likely to be unsuccessful. NOTES
The line numbers reported in error messages are usually off by one. FILES
List of common files used to build the system List of files specific to NAME, where NAME is the value specified for the ident option in the system configuration file Machine-independent portion of the makefile template used for building kernels from binaries Machine-independent portion of the makefile template used for building kernels from sources Machine-dependent portion of the makefile template List of machine- specific files Machine-specific name to major device mapping file RELATED INFORMATION
Commands: make(1), doconfig(8) System Administration delim off config(8)
All times are GMT -4. The time now is 02:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy