03-06-2007
In ennstate's post, I believe -c option will just return the count of occurance of the pattern.But here we need to find out if the pattern is present in the 2nd line...[if my understanding is correct].
I thnk the below approch will work well...
[[ $(grep -n 'this is first file' new1 | grep '2:this is first file') ]] && echo "Pattern found"
Also, we can use awk...
awk '{if ((NR==2) && ($0 == "this is first file" )) print "Pattern present" }' new1
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to determine whether a specific pattern is present within a line or not
e.g.
The whole line is in a varaible called VALUE
VALUE="(ABC, DEF, NMF, ABC, CLF, PAR, FHG, AGQSAs, sada, sa, ABC)"
i want to set a flag to 1 if i find the presence of ABC in the above variable.
Please... (8 Replies)
Discussion started by: skyineyes
8 Replies
2. Shell Programming and Scripting
Hi,
I have a script where I supply a parameter externally. Now when the script picks up the parameter, I want to verify if that parameter has a pattern such as "tag" in it.
I know that after reading the param the script can push it to a file and grep for the pattern, but I am looking for a... (2 Replies)
Discussion started by: sumeet
2 Replies
3. Shell Programming and Scripting
Hello friends,
I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed.
My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc..
I... (6 Replies)
Discussion started by: sreenu.shell
6 Replies
4. Shell Programming and Scripting
I want to check the files if the below pattern is there or not. I have to scan thousands of files.
It should start search with "Group" (Case insensitive) and followed by first semicolon ";" . In between these two there should be "partition"(case insensitive).
File1.txt
a)
update... (1 Reply)
Discussion started by: smolakal
1 Replies
5. Shell Programming and Scripting
HI Guys ,
Using UNIX ,I intend to check with correct file pattern Access_file_Record.YYYYMM in path /tmp
If the file exist in correct format come out from code .
If not found check with different file patterns for same month period YYYYMM ( Like Access_file_Record_YYYYMM.txt or... (8 Replies)
Discussion started by: Perlbaby
8 Replies
6. Shell Programming and Scripting
Hi ! All
I just want to search and write to new file if pattern is found in text file
following are my text files by which I want to search Month and last column number
my text file1
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25... (3 Replies)
Discussion started by: nex_asp
3 Replies
7. UNIX for Dummies Questions & Answers
Hey Guys and Gals,
I am having trouble with what I thought shouldn't be hard..
In a script I am working on there is a need to enter a MAC address.
MAC addresses are formatted ;
XX:XX:XX:XX:XX:XX
where X can be 0-9, a-f or A-F
So in the sample script the query is something... (4 Replies)
Discussion started by: TAPE
4 Replies
8. Shell Programming and Scripting
hi!
im new here and to unix.
I want to do something with our log files. to compare two log files for a certain pattern.
sample:
file1.log contains all the "successful" run of a procedure.
file2.log contains all the "current" running procedures.
sample line from file1.log... (5 Replies)
Discussion started by: cabs_14
5 Replies
9. Shell Programming and Scripting
Hi
I need to do a patten match between files .
I am new to shell scripting and have come up with this so far. It take 50 seconds to process files of 2mb size . I need to tune this code as file size will be around 50mb and need to save time.
Main issue is that I need to search the pattern from... (2 Replies)
Discussion started by: nitin_daharwal
2 Replies
10. Shell Programming and Scripting
Hi,
I've a file with content as below
first_block_list{
a:5
b:3
c:8
}
new_store_list(
a:1000
b:200
c:3343
)
first_item_list{
a:10
b:20
c:30
}
second_item_list{ (1 Reply)
Discussion started by: ratheeshp
1 Replies
LEARN ABOUT OPENDARWIN
cat
CAT(1) BSD General Commands Manual CAT(1)
NAME
cat -- concatenate and print files
SYNOPSIS
cat [-benstuv] [file ...]
DESCRIPTION
The cat utility reads files sequentially, writing them to the standard output. The file operands are processed in command-line order. If
file is a single dash ('-') or absent, cat reads from the standard input. If file is a UNIX domain socket, cat connects to it and then reads
it until EOF. This complements the UNIX domain binding capability available in inetd(8).
The options are as follows:
-b Number the non-blank output lines, starting at 1.
-e Display non-printing characters (see the -v option), and display a dollar sign ('$') at the end of each line.
-n Number the output lines, starting at 1.
-s Squeeze multiple adjacent empty lines, causing the output to be single spaced.
-t Display non-printing characters (see the -v option), and display tab characters as '^I'.
-u The -u option guarantees that the output is unbuffered.
-v Display non-printing characters so they are visible. Control characters print as '^X' for control-X; the delete character (octal
0177) prints as '^?'. Non-ASCII characters (with the high bit set) are printed as 'M-' (for meta) followed by the character for the
low 7 bits.
DIAGNOSTICS
The cat utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
The command:
cat file1
will print the contents of file1 to the standard output.
The command:
cat file1 file2 > file3
will sequentially print the contents of file1 and file2 to the file file3, truncating file3 if it already exists. See the manual page for
your shell (i.e., sh(1)) for more information on redirection.
The command:
cat file1 - file2 - file3
will print the contents of file1, print data it receives from the standard input until it receives an EOF ('^D') character, print the con-
tents of file2, read and output contents of the standard input again, then finally output the contents of file3. Note that if the standard
input referred to a file, the second dash on the command-line would have no effect, since the entire contents of the file would have already
been read and printed by cat when it encountered the first '-' operand.
SEE ALSO
head(1), more(1), pr(1), sh(1), tail(1), vis(1), zcat(1), setbuf(3)
Rob Pike, "UNIX Style, or cat -v Considered Harmful", USENIX Summer Conference Proceedings, 1983.
STANDARDS
The cat utility is compliant with the IEEE Std 1003.2-1992 (``POSIX.2'') specification.
The flags [-benstv] are extensions to the specification.
HISTORY
A cat utility appeared in Version 1 AT&T UNIX. Dennis Ritchie designed and wrote the first man page. It appears to have been cat(1).
BUGS
Because of the shell language mechanism used to perform output redirection, the command ``cat file1 file2 > file1'' will cause the original
data in file1 to be destroyed!
BSD
September 15, 2001 BSD