I am a complete newb to bash but am going to try and make a script to help me seach text files for strings of interest, any help that one of you gurus could pass on will be greatly received!!
I want to write something like:
in "text1.txt" find "string1" and copy out the line output to a new text file
e.g.
string1 this is the data that follows on from string1 for approximately 230 chars
I will eventually make the script more intelligent but this is just a start.
Hi and welcome to the forum and Unix community.
grep(1) is the tool you are looking for.
will output all lines that contain 'string1'
grep is a filter -- it is line based. It reads in a line, does a search, and prints the line if found; and takes the next line to process.
You can use -A<num> option to get <num> lines After the match, like this:
string to search for needs to be in double quotes if it contains spaces. Same for file. You can use variables, of course:
Look at the manual pages to find about grep's options on your system.
I have a file xyz with the following content
PPPL 0123
PPPL 0006
POFT 0923
POFT 1111
WENT 2323
SEND 2345
I also have another file named MasterFile where it contains the above mentioned data million times with different digits at the end for example some times it contains SEND 9999 or WENT... (4 Replies)
I have a text file which is generated when the batch job is run. This batch may take few mins to run. When completed, the last line of the text file would be process completed. I need a shell script which will wait for this file till the process completed is printed in it, once found, it would move... (2 Replies)
So, there is a large file where I have to conduct several search using bash shell scripting.
The file is like this:
TITLE and AUTHOR ETEXT NO. Aspects of plant life; with special reference to the British flora, 56900 by Robert Lloyd... (1 Reply)
Hello All
I have a pattern.txt file in source directory ((/project/source/) in linux server and data looks like:
123abc17
234cdf19
235ifg20
I have multiple log files in log directory (/project/log/) in linux server and data for one log file looks like:
<?xml version="1.0" processid... (11 Replies)
Hi folks,
I am new for shell script, I hope somebody to help me to write shell script
My requirement is below steps
1. I have apache access.log i.e located in /var/log/httpd/
Ex.
127.0.0.1 - - "GET... (14 Replies)
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Hi all
Am having records as below
file1
----
abc
12a
a2b
am trying to write a script to identify the character is present in the specified array
validchar=a b c d e 1
rec=`cat file1`
am getting the records in loop
for i in $rec
do (4 Replies)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
Hi,
We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below:
Process Beginning - 08-26-2010-23.41.47
DB2 CONNECTION SUCCESSFUL!
Ready to process and load file: FILENAME
# of... (2 Replies)
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)