Sponsored Content
Top Forums Shell Programming and Scripting Need to build Shell Script to search content of a text file into a folder consist several files Post 302555920 by ctsgnb on Friday 16th of September 2011 06:07:16 AM
Old 09-16-2011
Code:
$ cat f1
toto
titi

Code:
$ cat f2
jfdklsjfkldsq
jfdklsjfkldsq
toto
jfdklsjfkldsq
toto titi toto titi
jfdklsjfkldsq
titi
jfdklsjfkldsq

Code:
$ cat f3
toto
jfdklsjfkldsq
toto titi toto titi
jfdklsjfkldsq
titi

Code:
$ nawk 'NR==FNR{a[++c]=$0;next}{for(i in a) {if (match($0,a[i])) print FILENAME,a[i],FNR };next}' f1 f2 f3
f2 toto 3
f2 toto 5
f2 titi 5
f2 titi 7
f3 toto 1
f3 toto 3
f3 titi 3
f3 titi 5

also
Code:
$ nawk 'NR==FNR{a[++c]=$0;next}{d=1;do{if (match($0,a[d])) print FILENAME,a[d],FNR}while(++d in a);next}' f1 f2 f3
f2 toto 3
f2 toto 5
f2 titi 5
f2 titi 7
f3 toto 1
f3 toto 3
f3 titi 3
f3 titi 5


Last edited by ctsgnb; 09-16-2011 at 07:23 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to search content of file with timestamps in the directory

hello, i want to make a script to search the file contents in my home directory by a given date and output me the line that has the date... (10 Replies)
Discussion started by: psychobeauty
10 Replies

2. Shell Programming and Scripting

shell script to search a string and delete the content

Hi, I've a shell script e.g. #!/bin/bash echo "Enter the next hop id" read nhid echo "enter the IP address" read IP echo "enter the interface name" read name echo "enter the enable/disable state" read state exit 0 now from this script i want to search strings in another (.cam) ... (6 Replies)
Discussion started by: vic_mnnit
6 Replies

3. UNIX for Dummies Questions & Answers

Shell script to search for text in a file and copy file

Compete noob question.... I need a script to search through a directory and find files containing text string abcde1234 for example and then copy that file with that text string to another directory help please :eek: (9 Replies)
Discussion started by: imeadows
9 Replies

4. Shell Programming and Scripting

write shell script to search file in folder

hi .. i have a problem how to search file with date and version number(ms_2.0_dd/mm/yy_24)in folder.Here 24 is version number and compare the this file to other file which is in another folder and if does not match then copy this file to respective folder.Also copy different files in different... (1 Reply)
Discussion started by: shubhig15
1 Replies

5. Shell Programming and Scripting

Reading files under a folder and formatting content of each file

I have 'n' number of files in a folder .each file in the folder "myfolder" is having the content like. COLNAME ------------ AAAAAA BBBBBB CCCCCC DDDDDD ... ... ... ZZZZZZ 26 recrod(s) selected. My request is by reading each file in "myfolder" and format each file such a way... (18 Replies)
Discussion started by: rocking77
18 Replies

6. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

7. Shell Programming and Scripting

search for content in files. Name of files is in another file. Format as report.

Hi I have multiple files in a folder and one file which contains a list of files (one on each line). I was to search for a string only within these files and not the whole folder. I need the output to be in the form File1<tab>string instance 2<tab> string instance 2<tab>string instance 3... (6 Replies)
Discussion started by: pkabali
6 Replies

8. Shell Programming and Scripting

How to create a shell script to read a foldername from a text file and go to the folder?

Hi, I am trying to write a shell script which can read folder names from a text file and then go to the folder and picks up a xml file and write on my sipp script so that I can run the sipp script. For example: I have a text file called thelist.txt where I have provided all the folders... (7 Replies)
Discussion started by: pm1504
7 Replies

9. UNIX for Dummies Questions & Answers

How to sort a content of a text file using a shell script?

I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting. I've attached the 'Input file' and the 'expected output' to this thread. Details provided in the expected output file will provide details on how the sort needs to be done. ... (16 Replies)
Discussion started by: nkarthik_mnnit
16 Replies

10. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies
msh2geo(1rheolef)						    rheolef-6.1 						 msh2geo(1rheolef)

NAME
msh2geo - convert gmsh mesh in geo format SYNOPSIS
msh2geo [-zr|-rz] input[.msh] > output.geo DESCRIPTION
Convert a gmsh `.msh' into `.geo' one. The output goes to standart output. See the gmsh documentation for a detailed description of the `.mshcad' input file for gmsh. EXAMPLES
gmsh -2 toto.mshcad -o toto.msh msh2geo toto.msh > toto.geo gmsh -2 -order 2 toto.mshcad -o toto2.msh msh2geo toto2.msh > toto2.geo COORDINATE SYSTEM OPTION
Most of rheolef codes are coordinate-system independant. The coordinate system is specified in the geometry file `.geo'. -zr -rz the 2d mesh is axisymmetric: zr (resp. rz) stands when the symmetry is related to the first (resp. second) coordinate. NOTES
Pk triangle, when k>=5, may have internal nodes renumbered: from the GMSH DOCUMENTATION
The nodes of a curved element are numbered in the following order: the element principal vertices; the internal nodes for each edge; the internal nodes for each face; the volume internal nodes. The numbering for face and volume internal nodes is recursive, i.e., the numbering follows that of the nodes of an embedded face/volume. The higher order nodes are assumed to be equispaced on the element. In rheolef, internal triangle nodes are numbered from left to right and then from bottom to top. The numbering differ for triangle when k >= 5. Thus, msh2geo fix the corresponding internal nodes numbering during the conversion. Pk tetrahedrons and hexaedrons in gmsh and rheolef has not the same edge-node order nd orientation. E.g. for tetrahedrons, edges 13 and 23 should be swaped and reoriented as 32 and 31. Thus, msh2geo fix the corresponding internal nodes numbering. TODO
Fix for P3-tetra: swap edges orientations for 3,4,5 and swap faces 1 and 2. Check P4(T) for face orientation. Perform face visualisation with gnuplot face fill. See also hexa edges orient and faces numbers and orient. Check that node are numbered by vertex-node, then edge-node, then face(tri,qua)-node and then volume(T,P,H)-node. Otherwise, renumber all nodes. Support for high order >= 6 element ? not documented in gmsh, but gmsh supports it at run rheolef-6.1 rheolef-6.1 msh2geo(1rheolef)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy