Sponsored Content
Top Forums Shell Programming and Scripting sed or awk to replace a value in a certain line from another file containing a string Post 302655217 by elixir_sinari on Wednesday 13th of June 2012 01:53:30 AM
Old 06-13-2012
Assuming that mesh.k contains only 1 number:

Code:
awk 'NR==FNR{num=$1;next} /[0-9]{1,}\.k$/ {sub("[0-9]{1,}\.k$",num".k")} {print}' mesh.k input.k

This User Gave Thanks to elixir_sinari For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed conditional string replace for each line

Hi all, I appreciate the enormous amount of knowledge that flows in this forum. I am an average UNIX user. I have many files with lines like the below. I have separated each line with space for ease of reading. I need to replace the first occurance of "/00" with null on those lines that have... (6 Replies)
Discussion started by: Nanu_Manju
6 Replies

2. Shell Programming and Scripting

Appending string (charachters inside the line) to a fixed width file using awk or sed

Source File: abcdefghijklmnop01qrstuvwxyz abcdefghijklmnop02qrstuvwxyz abcdefghijklmnop03qrstuvwxyz abcdefghijklmnop04qrstuvwxyz abcdefghijklmnop05qrstuvwxyz Whatever characters are in 17-18 on each line of the file, it should be concatenated to the same line at the character number... (6 Replies)
Discussion started by: tamahomekarasu
6 Replies

3. Shell Programming and Scripting

How to find a certain string in a file and replace it with a value from another file using sed/awk?

Hi Everyone, I am new to this forum and new to sed/awk programming too !! I need to find particular string in file1(text file) and replace it with a value from another text file(file2) the file2 has only one line and the value to be replaced with is in the second column. file 1: (assert (=... (21 Replies)
Discussion started by: paramad
21 Replies

4. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

5. Shell Programming and Scripting

sed: how to replace string by another line

hi experts, i would like to do some html-file replacements and encounter the following problem: after cleaning up the file a bit i'd like to replace a regex with a reference and the content of another line. example: /<title>\(*\) - Wikipedia<\/title>/ should be replaced by \1 (the title... (2 Replies)
Discussion started by: chrisnie
2 Replies

6. Shell Programming and Scripting

sed or awk to replace a value in a certain line containing a string

hi experts , I have an input like following. R sfst 1000.0000 $ new time step for mass scaled calculation R dt2ms -4.000E-7 $ friction value for blank R mue ... (10 Replies)
Discussion started by: hamnsan
10 Replies

7. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
mkgeo_ugrid(1rheolef)						    rheolef-6.1 					     mkgeo_ugrid(1rheolef)

NAME
mkgeo_ugrid -- build an unstructured mesh of a parallelotope, in 1d, 2d or 3d SYNOPSIS
mkgeo_ugrid options [n] EXAMPLE
The following command build a triangle based 2d unstructured mesh of the unit square: mkgeo_ugrid -t 10 > square-10.geo geo -mayavi square-10.geo or in one comand line: mkgeo_ugrid -t 10 | geo -mayavi - DESCRIPTION
This command is usefull when testing programs on simple geometries. Invocation is similar to mkgeo_grid (see mkgeo_grid(1)). It calls gmsh as unstructured mesh generator. It avoid the preparation of an input file for a mesh generator. The optional n argument is an inte- ger that specifies the subdivision in each direction. By default n=10. The mesh files goes on standard output. The command supports all the possible element types: edges, triangles, rectangles, tetraedra, prisms and hexahedra. It supports also mixed 2D with triangles and quadrangles: mkgeo_ugrid -tq 10 | geo -mayavi - and mixed 3D with tetraedra, prisms and/or hjexaedra: mkgeo_ugrid -TP 10 | geo -mayavi - mkgeo_ugrid -PH 10 | geo -mayavi - mkgeo_ugrid -TPH 10 | geo -mayavi - ELEMENT TYPE OPTIONS
-e 1d mesh using edges. -t 2d mesh using triangles. -q 2d mesh using quadrangles. -tq 2d mesh using both triangles and quadrangles. -T 3d mesh using tetraedra. -P 3d mesh using prisms. -H 3d mesh using hexahedra. -TP -PH -TPH 3d mesh using a mixt between tetraedra, prisms and/or hexahedra. THE GEOMETRY
The geometry can be any [a,b] segment, [a,b]x[c,d] rectangle or [a,b]x[c,d]x[f,g] parallelotope. By default a=c=f=0 and b=d=g=1, thus, the unit boxes are considered. For instance, the following command meshes the [-2,2]x[-1.5, 1.5] rectangle: mkgeo_ugrid -t 10 -a -2 -b 2 -c -1.5 -d 1.5 | geo - -a float -b float -c float -d float -f float -g float BOUNDARY DOMAINS
-sides -nosides The boundary sides are representd by domains: left, right, top, bottom,front and back. -boundary -noboundary This option defines a domain named boundary that groups all sides. By default, both sides and the whole boundary are defined as domains: mkgeo_ugrid -t 10 > square.geo geo square.geo mkgeo_ugrid -t 10 -nosides > square.geo geo square.geo mkgeo_ugrid -t 10 -noboundary > square.geo geo square.geo mkgeo_ugrid -t 10 -noboundary -nosides > square.geo geo square.geo REGIONS
-region -noregion The whole domain is splitted into two subdomains: east and west, This option is used for testing computations with subdomains (e.g. transmission problem; see the user manual). mkgeo_ugrid -t 10 -region | geo - CORNERS
-corner -nocorner The corners (four in 2D and eight in 3D) are defined as OD-domains. This could be usefull for some special boundary conditions. mkgeo_ugrid -t 10 -corner | geo - mkgeo_ugrid -T 5 -corner | geo - THE MESH ORDER
-order int The polynomial approximation mesh order, as defined by gmsh. This option enable a possible curved boundary, when applying a suit- able nonlinear transformation to the mesh. Defualt is order=1. OTHERS OPTIONS
-clean clear temporary files (this is the default). -noclean does not clear temporary files. SEE ALSO
mkgeo_grid(1) rheolef-6.1 rheolef-6.1 mkgeo_ugrid(1rheolef)
All times are GMT -4. The time now is 08:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy