Hi there,
I need help about using sed. Iam using sed to delete and print lines that match the port number as listed in sedfile. I am using -d and -p command for delete match port and print them respectively. However, the output is not synchonize where the total deleted lines is not similar with... (3 Replies)
Dear all,
I need to search multiple patterns and then I need to print their respective next lines. For an example, in the below table, I will look for 3 different patterns :
1) # ATC_Codes:
2) # Generic_Name:
3) # Drug_Target_1_Gene_Name:
#BEGIN_DRUGCARD DB00001
# AHFS_Codes:... (3 Replies)
Hi,
I have a large, multiline log file.
I have used pcregrep to extract all entries in that log that match a particular pattern - where that pattern spans multiple lines.
However, because the log file is large, and these entries occur every few minutes, I still output a very large amount... (6 Replies)
I want to search a bunch of files and list only those containing a minimum number of pattern matches. So if I want to identify files containing 3 (or more) instances of the pattern "said:" and I have file1 that contains the lines:
He said:
She said:
and file2 that contains the lines:
He... (3 Replies)
Hi,
i have been trying to extract multiple lines based on two different patterns as below:-
file1
@jkm|kdo|aas012|192.2.3.1 blablbalablablkabblablabla
sjfdsakfjladfjefhaghfagfkafagkjsghfalhfk
fhajkhfadjkhfalhflaffajkgfajkghfajkhgfkf
jahfjkhflkhalfdhfwearhahfl
@jkm|sdf|wud08q|168.2.1.3... (8 Replies)
Hi,
I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example:
inputfile
abd abp 123
abc abc 325
ndc ndc 451
mjk lkj... (3 Replies)
Hi,
I could only find examples to print line before/after a match, but I'd need to print line after two separate lines matching.
E.g.: From the below log entry, I would need to print out the 1234. This is from a huge log file, that has a lot of entries with "CLIENT" and "No" entries (+ other... (3 Replies)
In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
LEARN ABOUT OPENDARWIN
switch
switch(n) Tcl Built-In Commands switch(n)
__________________________________________________________________________________________________________________________________________________NAME
switch - Evaluate one of several scripts, depending on a given value
SYNOPSIS
switch ?options? string pattern body ?pattern body ...?
switch ?options? string {pattern body ?pattern body ...?}
_________________________________________________________________DESCRIPTION
The switch command matches its string argument against each of the pattern arguments in order. As soon as it finds a pattern that matches
string it evaluates the following body argument by passing it recursively to the Tcl interpreter and returns the result of that evaluation.
If the last pattern argument is default then it matches anything. If no pattern argument matches string and no default is given, then the
switch command returns an empty string.
If the initial arguments to switch start with - then they are treated as options. The following options are currently supported:
-exact Use exact matching when comparing string to a pattern. This is the default.
-glob When matching string to the patterns, use glob-style matching (i.e. the same as implemented by the string match command).
-regexp When matching string to the patterns, use regular expression matching (as described in the re_syntax reference page).
-- Marks the end of options. The argument following this one will be treated as string even if it starts with a -.
Two syntaxes are provided for the pattern and body arguments. The first uses a separate argument for each of the patterns and commands;
this form is convenient if substitutions are desired on some of the patterns or commands. The second form places all of the patterns and
commands together into a single argument; the argument must have proper list structure, with the elements of the list being the patterns
and commands. The second form makes it easy to construct multi-line switch commands, since the braces around the whole list make it unnec-
essary to include a backslash at the end of each line. Since the pattern arguments are in braces in the second form, no command or vari-
able substitutions are performed on them; this makes the behavior of the second form different than the first form in some cases.
If a body is specified as ``-'' it means that the body for the next pattern should also be used as the body for this pattern (if the next
pattern also has a body of ``-'' then the body after that is used, and so on). This feature makes it possible to share a single body among
several patterns.
Beware of how you place comments in switch commands. Comments should only be placed inside the execution body of one of the patterns, and
not intermingled with the patterns.
Below are some examples of switch commands:
switch abc a - b {format 1} abc {format 2} default {format 3}
will return 2,
switch -regexp aaab {
^a.*b$ -
b {format 1}
a* {format 2}
default {format 3}
}
will return 1, and
switch xyz {
a
-
b
{
# Correct Comment Placement
format 1
}
a*
{format 2}
default
{format 3}
}
will return 3.
SEE ALSO
for(n), if(n), regexp(n)
KEYWORDS
switch, match, regular expression
Tcl 7.0 switch(n)