Sponsored Content
Full Discussion: Using sed in a for loop
Top Forums UNIX for Dummies Questions & Answers Using sed in a for loop Post 302751635 by hergp on Friday 4th of January 2013 08:18:12 AM
Old 01-04-2013
You are using the -i option, which means inplace-update. Therefore the redirection of standard output is obsolete and nothing should be written to the *.header files.

After the loop, the *.profile files hold the contents with the new headers and the *.bak the original contents.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: chiru_h
2 Replies

2. 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

3. Shell Programming and Scripting

Using sed with a foreach loop

So I am back again beating my head against the wall with a shell script and getting a headache! I want to change each year in a file (1980, 1981, 1982, 1983, etc.) to the same year followed by a tab. The input is "blah blah (1980) blah blah". I want to get "blah blah (1980 ) blah blah".... (2 Replies)
Discussion started by: Peggy White
2 Replies

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

SED inside while loop

Hi, im having problem creating a loop using my code: aside from the fact that the 1st variable (VAR) does not increment, it loops more than the expected output. for sample purposes, test csv contains 3 lines. #get number of lines in the file lines=$( wc -l < test.csv ) ... (5 Replies)
Discussion started by: paoie
5 Replies

7. 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

8. Shell Programming and Scripting

Need help using sed inside the loop.

Hi, i have written a script. it collects data based on the sql queries executed by it. i have multiple output files. after the output file is made i need to do some cosmetic changes in the files and then store them. i am unable to use sed conditions inside the loop. see below code for... (3 Replies)
Discussion started by: dazdseg
3 Replies

9. Shell Programming and Scripting

Using variables in a sed loop...

Hi all, I'm trying to search for the first field in a file called vintella.sudoers_1 and then use the result to grep for its match in vintella.sudoers_useralias file but assigning the second field of what it finds to another variable called to_replace. I then want to use that to_replace... (9 Replies)
Discussion started by: Jazmania
9 Replies

10. 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
ANNO(1) 							     [nmh-1.5]								   ANNO(1)

NAME
anno - annotate messages SYNOPSIS
anno [+folder] [msgs] [-component field] [-inplace | -noinplace] [-date | -nodate] [-draft] [-append] [-list] [-delete] [-number [num|all]] [-preserve | -nopreserve] [-version] [-help] [-text body] DESCRIPTION
Anno manipulates header fields or annotations in messages. Header fields consist of a field name and an optional field body as defined by RFC-2822. The -component option specifies the field name, and the -text option specifies the field body. The messages are either the msgs in the named folder, or the draft if invoked with the -draft option. Usually, annotation is performed by the commands dist, forw, and repl, if they are given the -anno switch. This allows you to keep track of your distribution of, forwarding of, and replies to a message. By using anno, you can perform arbitrary annotations of your own. Each message selected will be annotated with the lines field: date field: body The -nodate switch inhibits the date annotation, leaving only the body annotation. By default, anno prepends the annotations to the message. Annotations are instead appended if the -append option is specified. If a -component field is not specified when anno is invoked, anno will prompt the user for the name of field for the annotation. The field specified must be a valid 2822-style message field name, which means that it may only consist of alphanumerics and dashes, The body specified is arbitrary text. Normally anno does the annotation inplace in order to preserve any links to the message. You may change this by using the -noinplace switch. The -list option produces a listing of the field bodies for header fields with names matching the specified component, one per line. The listing is numbered, starting at 1, if the -number option is also used. A tab character separates the number and the field body. The field body is treated as if it is a file name, and only the final path name component is listed. The complete field body is listed if the -text option is used, the contents of the text are ignored. The -delete option removes header fields from messages. The first header field whose name matches the component is deleted if no other options are specified. If the -text option is used in conjunction with the -delete option, the first header field whose name matches the component and whose body matches the text is deleted. The text is treated as if it was a file name; if it begins with a slash, the entire field body must match the text, otherwise just the last path name component of the field body must match. If the -number option is used in conjuction with the -delete option, header field num whose name matches the component is deleted. The number matches that which is pro- duced by the -list option. The special value all can be used for the number, and causes all components that match the name to be deleted. By default, anno changes the last-accessed and last-modified times on annotate messages to the time at which the annotation occurs. Anno preserves the original times if the -preserve option is used. A matching -nopreserve option exists that allows time preservation to be turned off if enabled in the profile. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
dist(1), forw(1), repl(1) DEFAULTS
`+folder' defaults to the current folder `msgs' defaults to cur `-inplace' `-date' CONTEXT
If a folder is given, it will become the current folder. The first message annotated will become the current message. MH.6.8 11 June 2012 ANNO(1)
All times are GMT -4. The time now is 12:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy