Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Problem with sed in for loop, would appreciate some help Post 303041843 by andrevol on Thursday 5th of December 2019 04:13:21 AM
Old 12-05-2019
1. Thank you so much, that is immediately helpful! Smilie Didn't know while loops in UNIX.
2. The copying was intended, since I need a changed version of the template.fsf in each folder (which is then run later in the script). This is the only way I know so far of doing this.
3. Yeah, the template.fsf is a text file generated by FSL specifying details of a fMRI analysis, and I'm hoping to edit it in the loop. The stimruns.txt file for each subject only contains a column vector of numbers I want to loop over within a folder of a subject, and the subjlist.txt a column vector of foldernames (subject folders) I want to loop over.

--- Post updated at 10:13 AM ---

Oh, it's bash shell Smilie
 

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

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

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

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

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

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

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

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

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

NAME
comp - compose a message SYNOPSIS
comp [+folder] [msg] [-form formfile] [-use | -nouse] [-file file] [-draftfolder +folder] [-draftmessage msg] [-nodraftfolder] [-editor editor] [-noedit] [-width columns] [-from address] [-to address] [-cc address] [-fcc +folder] [-subject text] [-whatnowproc program] [-nowhatnowproc] [-version] [-help] DESCRIPTION
Comp is used to create a new message to be mailed. It copies a message form to the draft being composed and then invokes an editor on the draft (unless -noedit is given, in which case the initial edit is suppressed). The default message template "components" will direct comp to construct the message draft as follows: From: {from switch} or <Local-Mailbox> or <username@hostname> To: {to switch} or blank cc: {cc switch} or blank Fcc: {fcc switch} or +outbox Subject: {subject switch} or blank -------- If a file named "components" exists in the user's nmh directory, it will be used instead of this form. You may specify an alternate forms file with the switch -form formfile. You may also start comp using the contents of an existing message as the form. If you supply either a +folder or msg argument, that mes- sage will be used as the message form. You may not supply both a -form formfile and a +folder or msg argument. The line of dashes or a blank line must be left between the header and the body of the message for the message to be identified properly when it is sent (see send(1)). The switch -use directs comp to continue editing an already started message. That is, if a comp (or dist, repl, or forw) is terminated without sending the draft, the draft can be edited again via "comp -use". The -file file switch says to use the named file as the message draft. Forms that are selected via the -form switch are processed via the nmh template system; see mh-format(5) for details. Drafts constructed from another message or with the -use or -file switchs will NOT be processed with mh-format(5). In addition to the standard mh-format(5) escapes, the following component escapes are either new or have an alternate meaning: Escape Returns Description fcc string Any folders specified with `-fcc folder' from string Any addresses specified with `-from address' to string Any addresses specified with `-to address' cc string Any addresses specified with `-cc address' subject string Any text specified with `-subject text' By default the "To:" and "cc:" fields are empty. You may add addresses to these fields with the -to address and -cc address switches. You may give these switches multiple times to add multiple addresses. By default the "From:" field has either the value of the Local-Mailbox profile entry or a system default email address. This default can be overridden by using the -from address switch. The default mailbox in the "Fcc:" field is +outbox. This can be overridden by the -fcc switch. Any text you give to the -subject switch will be placed in the "Subject:" field in the draft. If the draft already exists, comp will ask you as to the disposition of the draft. A reply of quit will abort comp, leaving the draft intact; replace will replace the existing draft with the appropriate form; list will display the draft; use will use the draft for further composition; and refile +folder will file the draft in the given folder, and give you a new draft with the appropriate form. (The +folder argument to refile is required.) The -draftfolder +folder and -draftmessage msg switches invoke the nmh draft folder facility. This is an advanced (and highly useful) fea- ture. Consult the mh-draft(5) man page for more information. The -editor editor switch indicates the editor to use for the initial edit. Upon exiting from the editor, comp will invoke the whatnow program. See whatnow(1) for a discussion of available options. The invocation of this program can be inhibited by using the -nowhatnow- proc switch. (In truth of fact, it is the whatnow program which starts the initial edit. Hence, -nowhatnowproc will prevent any edit from occurring.) FILES
/etc/nmh/components The standard message skeleton or <mh-dir>/components Rather than the standard skeleton $HOME/.mh_profile The user profile <mh-dir>/draft The draft file PROFILE COMPONENTS
Path: To determine the user's nmh directory Draft-Folder: To find the default draft-folder Editor: To override the default editor Msg-Protect: To set mode when creating a new message (draft) fileproc: Program to refile the message whatnowproc: Program to ask the "What now?" questions SEE ALSO
dist(1), forw(1), repl(1), send(1), whatnow(1), mh-profile(5) DEFAULTS
`+folder' defaults to the current folder `msg' defaults to the current message `-nodraftfolder' `-nouse' CONTEXT
None BUGS
If whatnowproc is whatnow, then comp uses a built-in whatnow, it does not actually run the whatnow program. Hence, if you define your own whatnowproc, don't call it whatnow since comp won't run it. MH.6.8 11 June 2012 COMP(1)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy