Sponsored Content
Top Forums Shell Programming and Scripting bash: need to have egrep to return a text string if the search pattern has NOT been found Post 302669281 by methyl on Tuesday 10th of July 2012 08:27:33 PM
Old 07-10-2012
What is the expected output, based on the data provided?

Ps. The input data looks pretty random to me. Is there a formal file structure? Can you explain it?
There is no way that someone can write code to processs the sample input provided - it's full of abstracts and random comments.

Last edited by methyl; 07-10-2012 at 09:39 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Using egrep to search for Text and special char

Anyone is well-versed to use egrep to search a file for a line containing both: 1) AAA 2) $ I am having problem escaping the dollar sign when using egrep in conjunction with satisfying AAA as well. E.g. Text file Line 1 AAA Line 2 $$$ Line 3 AAA BBB $ Line 4 $$$ BBB AA will return me... (2 Replies)
Discussion started by: izy100
2 Replies

2. Shell Programming and Scripting

Help with pattern search and return

I would like to write a script which will read a file containing a list of filenames of the format as shown below : /usr/local/packages/runcmdlinetool /home/john.doe/sdfsdf/sdfsdfsd/sdfsdf/sdfsdfTemplates.xml /usr/local/bin/gtar... (4 Replies)
Discussion started by: inditopgun
4 Replies

3. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

4. Shell Programming and Scripting

extract specific line if the search pattern is found

Hi, I need to extract <APPNUMBER> tag alone, if the <college> haas IIT Chennai value. college tag value will have spaces embedded. Those spaces should not be suppresses. My Source file <Record><sno>1</sno><empid>E0001</empid><name>Rejsh suderam</name><college>IIT ... (3 Replies)
Discussion started by: Sekar1
3 Replies

5. UNIX for Dummies Questions & Answers

Search specific pattern in file and return number of occurence

Hi I want to search for a specific pattern in file Say ABC;HELLO_UNIX_WORLD;PQR ABC;HELLO_UNIX_WORLD_IS_NOT_ENOUGH;XYZ ABC;HELLO_UNIX_FORUM;LMN Pattern to search is : "HELLO_UNIX_*****" and not "HELLO_UNIX_***_***_" I mean after "HELLO_UNIX" there can only be one word.In this case... (2 Replies)
Discussion started by: dashing201
2 Replies

6. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

7. Shell Programming and Scripting

Avoid carriage return until ^M is found (CentOS 6, bash 4.1)

Hi everyone, I have the following contents in a text file (as seen when viewed using vim): one two three ^M four five six ^M seven eight nine ^M ten eleven twelve ^M (That is just a small portion of the file) How can I obtain the following result? one two three ^M four five six ^M seven... (2 Replies)
Discussion started by: gacanepa
2 Replies

8. UNIX for Dummies Questions & Answers

How to find a file based on pattern & return the filename if found?

Hi all, I am a newbie here. I have this requirement to find a file based on a pattern then return the filename if found. I created a script based on online tutorials. Though, I am stuck & really appreciate if anyone can have a quick look & point me to the right direction? #Script starts... (10 Replies)
Discussion started by: buster_t
10 Replies

9. Shell Programming and Scripting

Search a text and return the text from file

Hi I have a set of input strings in a pattern as given below string1 string2 string3 string4 string5 I need to search this sequence of strings from a file in such a way that the first two strings (string1 and string2) and last two strings (string4 and string5) should match with the... (8 Replies)
Discussion started by: my_Perl
8 Replies

10. Shell Programming and Scripting

Bash to search file for string and lauch function if found

In the bash below I am searching the filevirus-scan.log for the Infected files: 0 line (in bold) and each line for OK. If both of these are true then the function execute is automatically called and processing starts. If both these conditions are not meet then the line in the file is sent to the... (2 Replies)
Discussion started by: cmccabe
2 Replies
GETENTROPY(2)						      BSD System Calls Manual						     GETENTROPY(2)

NAME
getentropy -- get entropy SYNOPSIS
#include <sys/random.h> int getentropy(void *buf, size_t buflen); DESCRIPTION
getentropy() fills a buffer with random data, which can be used as input for process-context pseudorandom generators like arc4random(3). The maximum buffer size permitted is 256 bytes. If buflen exceeds this, an error of EIO will be indicated. getentropy() should be used as a replacement for random(4) when random data derived directly from the kernel random byte generator is required. Unlike the random(4) pseudo-devices, it is not vulnerable to file descriptor exhaustion attacks and is available when sandboxed or in a chroot, making it more reliable for security-critical applications. However, it should be noted that getentropy() is primarily intended for use in the construction and seeding of userspace PRNGs like arc4random(3) or CC_crypto(3). Clients who simply require random data should use arc4random(3), CCRandomGenerateBytes() from CC_crypto(3), or SecRandomCopyBytes() from the Security framework instead of getentropy() or random(4) RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
getentropy() will succeed unless: [EINVAL] The buf parameter points to an invalid address. [EIO] Too many bytes requested, or some other fatal error occurred. SEE ALSO
arc4random(3) CC_crypto(3) random(4) HISTORY
The getentropy() function appeared in OSX 10.12 BSD
October 2 2015 BSD
All times are GMT -4. The time now is 10:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy