Sponsored Content
Top Forums Shell Programming and Scripting Grep a pattern given in one file at other file and display its corresponding contents as output. Post 302488223 by abinash on Sunday 16th of January 2011 05:46:09 AM
Old 01-16-2011
Awesome thanks :-)

Is it possible to get the line number of the occurrence along with the output? from the above example, "this is the line1 which is suppose to be grepped and displayed as a output." is at second line. So the output should be as,

2: line one found
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to display correctly the contents of a file without a line feed

I am using AIX and ksh. I need to display the contents of a file that has a pid (process id). Because the file is open, it doesn't have the line feed or new line, so for some reason if I do this: `cat $pid` , where $pid is the name of the fully qualified file, it displays test3.sh: 426110:... (1 Reply)
Discussion started by: Gato
1 Replies

2. Shell Programming and Scripting

Grep pattern from different file and display if it exists in the required file

Hi, I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg. "this is the line1" "this is the line2" The yyy.txt with lot of lines. eg: "This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
Discussion started by: abinash
3 Replies

3. Shell Programming and Scripting

sed command for copying the contents of other file replacing it another file on specifc pattern

We have 2 file XML files - FILE1.XML and FILE2.xml - we need copy the contents of FILE1.XML and replace in FILE2.xml pattern "<assignedAttributeList></assignedAttributeList>" FILE1.XML 1. <itemList> 2. <item type="Manufactured"> 3. <resourceCode>431048</resourceCode> 4. ... (0 Replies)
Discussion started by: balrajg
0 Replies

4. Shell Programming and Scripting

script to grep a pattern from file compare contents with another file and replace

Hi All, Need help on this I have 2 files one file file1 which has several entries as : define service{ hostgroup_name !host1,!host5,!host6,.* service_description check_nrpe } define service{ hostgroup_name !host2,!host4,!host6,.* service_description check_opt } another... (2 Replies)
Discussion started by: namitai
2 Replies

5. Shell Programming and Scripting

Grep -v contents of a list file from another file.

Hello, I am trying to get output from FILE2 that excludes servers from list FILE1. I've tried a for loop with no success. Any ideas how to go about this? FILE1 contains: server1 server2 server3 server4 server5 FILE2 contains: server1:ERROR:user1: error message... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

6. Shell Programming and Scripting

Help with ksh script to display output with specific contents

This is Input - starts with Storage Group Name and ends with Shareable and the loop continues all I need is Storage group name and Alu numbers in the below output format requested. Storage Group Name: abcd Storage Group UID: 00:00:000:00:0:0:0 HBA/SP Pairs: HBA UID ... (6 Replies)
Discussion started by: maddysa
6 Replies

7. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

8. UNIX for Dummies Questions & Answers

HTML: Display contents of file using Variable

<tr><td bgcolor=#D7EBAD><b>Instructions :</b></td> <td>`cat temp.txt`</td></tr> Hi Experts, I have an requirement of displaying file contents in HTML mail , for which am using the above approach, Where as the output is kind of not as expected. If there are 5 lines in the file, in the... (4 Replies)
Discussion started by: scott_cog
4 Replies

9. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

10. UNIX for Beginners Questions & Answers

Output file name and file contents of multiple files to a single file

I am trying to consolidate multiple information files (<hostname>.Linux.nfslist) into one file so that I can import it into Excel. I can get the file contents with cat *Linux.nfslist >> nfslist.txt. I need each line prefaced with the hostname. I am unsure how to do this. --- Post updated at... (5 Replies)
Discussion started by: Kentlee65
5 Replies
MATHO-PRIMES(1) 					       Mathomatic Utilities						   MATHO-PRIMES(1)

NAME
matho-primes - generate consecutive prime numbers SYNOPSIS
matho-primes [start [stop]] ["twin"] ["pal" [base]] matho-primes [-htu] [-c count] [-m number] [-p base] [start [stop]] DESCRIPTION
This command-line utility is optionally part of the mathomatic(1) package. It quickly computes any number of consecutive prime numbers using a windowing, memory efficient sieve of Eratosthenes algorithm, dumping them to standard output. They are displayed one prime per line in ascending order, unless the "twin" option is specified, which displays only twin primes, two primes per line. Generates up to 18 decimal digit primes, or whatever is the number of digits of precision for a floating point long double in the C com- piler used to compile this utility. Note that this utility might be compiled to use only double precision floating point, if long double precision is not fully supported by the C compiler or hardware, allowing at most 15 decimal digit primes in that case. Ways to verify that this utility is working are to pipe the output into the Unix "factor" utility, or compare the output with the BSD Games "primes" utility. All numbers displayed by this utility are decimal (base 10) prime numbers. A prime number is an integer that cannot be factored. A range may be specified on the command line, otherwise the starting number and the number of primes to output is prompted for. The range is start to stop inclusive, and stop must be greater than or equal to start. If the -c option is specified, the number of lines of primes displayed is limited to the decimal count that follows this option. If the -t or "twin" option is specified on the command line, only twin primes will be displayed. Twin primes are two primes that differ in value by 2. Each twin pair is displayed together on the same line separated by a space character. If the -p or "pal" option is specified on the command line, only palindromic primes are displayed. Palindromes are symmetrical, they read exactly the same forward and backward. The palindromic number base may be specified, the default is base 10. The base can be any integer greater than 1. Primes are always displayed in decimal (base 10). The version number and short help on the allowed command-line parameters and usage information are displayed when given the -h option. With the -u option, all output (standard output and standard error output) is set to be unbuffered, making all output happen immediately, instead of when the output buffer is full or when the program terminates or waits for input. The -m option changes the memory size of the prime number sieve window. It is followed by a decimal, floating point number which is a mul- tiplier of the default window size. It is possible that changing the memory size may speed up the total run time; otherwise there is no reason to use this option. AUTHOR
George Gesslein II (gesslein@mathomatic.org) at "http://www.mathomatic.org". REPORTING BUGS
If you find a bug, please report it to the author or at "https://launchpad.net/mathomatic". SEE ALSO
mathomatic(1), primorial(1), matho-mult(1), matho-sum(1) Mathomatic MATHO-PRIMES(1)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy