Sponsored Content
Top Forums Shell Programming and Scripting Extract a number from a line in a file and sed in another copied file Post 302479631 by 116@434 on Sunday 12th of December 2010 01:26:04 AM
Old 12-12-2010
Please try this within the loop and check:

Code:
temp=`sed "${k}s/^[^0-9]*\([0-9]*\).*$/\1/g" temperatures`; #Task 1

cp nvt.mdp nvt_$k.mdp; #Task 2

sed 's/300/$temp/g' < nvt_$k.mdp > ${k}_nvt.mdp; #Task 3

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED: Update Last Line with Number Lines in File

Hi, I have to update last line of a text file with the number of lines in that file. This last line will have text such as 0.0000 and I should replace this with number lines. If lines are 20 then it should be replaced with 00020. Any sed or awk cmd help would be appreciated (3 Replies)
Discussion started by: bmkux
3 Replies

2. Shell Programming and Scripting

Extract a line from a file using the line number

I have a shell script and want to assign a value to a variable. The value is the line exctrated from a file using the line number. The line number it is not fix, and could change any time. I have tried sed, awk, head .. See my script # Get randome line number from the file #selectedline = `awk... (1 Reply)
Discussion started by: zambo
1 Replies

3. Shell Programming and Scripting

extract a line from a file using the line number

Hello, I am having trouble extracting a specific line from a file when the line number is known. My first attempt involved grep -n 'hi' (the word 'hi will always be there) to get the line number before the line that I actually want (line 4). Extra Notes: -I am working in a bash script. -The... (7 Replies)
Discussion started by: grandtheftander
7 Replies

4. Shell Programming and Scripting

extract the lines between specific line number from a text file

Hi I want to extract certain text between two line numbers like 23234234324 and 54446655567567 How do I do this with a simple sed or awk command? Thank you. ---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ---------- found it: sed -n '#1,#2p'... (1 Reply)
Discussion started by: return_user
1 Replies

5. Shell Programming and Scripting

Help on Sed/awk/getting line number from file

I Have file1 with below lines : #HostNameSelection=0 :NotUsed #HostNameSelection=1 :Automatic #HostNameSelection=3 :NotForced I have file2 which has similar lines but with different values I want to copy the changes from file1 to file2 ,line by line only if line begins with '#'. for... (7 Replies)
Discussion started by: mvr
7 Replies

6. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

7. Shell Programming and Scripting

extract a line from a file by line number

Hi guys, does anyone know how to extract(grep) a line from the file, if I know the line number? Thanks a lot. (9 Replies)
Discussion started by: aoussenko
9 Replies

8. Shell Programming and Scripting

Perl extract number from file & write to file

I have 1 file that has elements as follows. Also the CVR(10) and the word "SAUCE" only appear once in the file so maybe a grep command would work? file1 CVR( 9) = 0.385E+05, ! VEHICLE CVR(10) = 0.246E+05, ! SAUCE CVR(11) = 0.162E+03, ! VEHICLE I need to extract the... (6 Replies)
Discussion started by: austinj
6 Replies

9. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

10. Shell Programming and Scripting

Using sed to extract line of a file

Ok .. This is driving me nuts. I suppose I need another set of eyes. Example Data interface Vlan1 description xxxxxxxxxxxx ip address 192.168.1.1 255.255.255.252 no ip redirects no ip proxy-arp ip flow ingress ip pim sparse-mode load-interval 30 ! interface Vlan2 ... (5 Replies)
Discussion started by: popeye
5 Replies
MDCHAIN(9)						   BSD Kernel Developer's Manual						MDCHAIN(9)

NAME
mdchain, md_initm, md_done, md_append_record, md_next_record, md_get_uint8, md_get_uint16, md_get_uint16be, md_get_uint16le, md_get_uint32, md_get_uint32be, md_get_uint32le, md_get_int64, md_get_int64be, md_get_int64le, md_get_mem, md_get_mbuf, md_get_uio -- set of functions to dissect an mbuf chain to various data types SYNOPSIS
options LIBMCHAIN kldload libmchain #include <sys/param.h> #include <sys/uio.h> #include <sys/mchain.h> void md_initm(struct mdchain *mdp, struct mbuf *m); void md_done(struct mdchain *mdp); void md_append_record(struct mdchain *mdp, struct mbuf *top); int md_next_record(struct mdchain *mdp); int md_get_uint8(struct mdchain *mdp, u_int8_t *x); int md_get_uint16(struct mdchain *mdp, u_int16_t *x); int md_get_uint16be(struct mdchain *mdp, u_int16_t *x); int md_get_uint16le(struct mdchain *mdp, u_int16_t *x); int md_get_uint32(struct mdchain *mdp, u_int32_t *x); int md_get_uint32be(struct mdchain *mdp, u_int32_t *x); int md_get_uint32le(struct mdchain *mdp, u_int32_t *x); int md_get_int64(struct mdchain *mdp, int64_t *x); int md_get_int64be(struct mdchain *mdp, int64_t *x); int md_get_int64le(struct mdchain *mdp, int64_t *x); int md_get_mem(struct mdchain *mdp, caddr_t target, int size, int type); int md_get_mbuf(struct mdchain *mdp, int size, struct mbuf **m); int md_get_uio(struct mdchain *mdp, struct uio *uiop, int size); DESCRIPTION
These functions are used to decompose mbuf chains to various data types. The mdchain structure is used as a working context and should be initialized through a call of the mb_initm() function. It has the following fields: md_top (struct mbuf *) A pointer to the top of the parsed mbuf chain. md_cur (struct mbuf *) A pointer to the currently parsed mbuf. md_pas (int) Offset in the current mbuf. The md_done() function disposes of an mbuf chain pointed to by the mdp->md_top field and sets the field to NULL. The md_append_record() appends a new mbuf chain using m_nextpkt field to form a single linked list of mbuf chains. If the mdp->md_top field is NULL, then this function behaves exactly as the md_initm() function. The md_next_record() function extracts the next mbuf chain and disposes the current one, if any. For a new mbuf chain it calls the md_initm() function. If there is no data left the function returns ENOENT. All md_get_*() functions perform an actual copy of the data from an mbuf chain. Functions which have le or be suffixes will perform conver- sion to the little- or big-endian data formats. md_get_mem() function copies size bytes of data specified by the source argument from an mbuf chain. The type argument specifies the method used to perform a copy, and can be one of the following: MB_MSYSTEM Use the bcopy() function. MB_MUSER Use the copyin(9) function. MB_MINLINE Use an ``inline'' loop which does not call any function. If target is NULL, an actual copy is not performed and the function just skips the given number of bytes. RETURN VALUES
All int functions return zero if successful, otherwise an error code is returned. Note: after failure of any function, an mbuf chain is left in the broken state and only the md_done() function can safely be called to destroy it. EXAMPLES
struct mdchain *mdp; struct mbuf *m; u_int16_t length; u_int8_t byte; receive(so, &m); md_initm(mdp, m); if (md_get_uint8(mdp, &byte) != 0 || md_get_uint16le(mdp, &length) != 0) error = EBADRPC; mb_done(mdp); SEE ALSO
mbchain(9), mbuf(9) AUTHORS
This manual page was written by Boris Popov <bp@FreeBSD.org>. BSD
February 28, 2001 BSD
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy