The -n option suppresses the automatic output of input lines (that's the default).
The p at the end tells sed to output the lines that matches.
This searches for lines at the left side of the division operator.
The characters within the brackets search for a numeric character or a variable and the space and asteric after the brackets for zero or more spaces.
This is the escaped division operator.
At the right side of the division operator we search for zero or more preceded spaces and a numeric character or a variable.
Regards
Last edited by Franklin52; 11-17-2007 at 09:50 AM..
Reason: typo
Hi,
I've searched this site and not found this already, so if I missed on my search, sorry.
I need to pass in a variable to a script, where the first three characters of that variable represent a calendar quarter, and the last 2 characters are the year. I.E. Q0105 for Q1, Q0205 for Q2, and... (3 Replies)
Hello All
I would like to search for files containing certain string pattern under all the directories under /vobs/vobname and print the output to a file in my home directory. How can I do this?
Note: /vobs/vobname conatins several directories.
Thank You in advance
newbetounix (1 Reply)
Hello All,
i have to search a pattern in all the files in all subfolders that are present in current directory.
suppose i am in d1 directory and in that sd1,sd2,sd3 are subdirectories.
in
sd1 i have files f1,f2
sd2 i have files f3,f4
sd3 i have file f5
i have to list out all those... (4 Replies)
Hi All,
Please can someone assist in the script I have made that searches a pattern in a file and delete the whole line containing the pattern.
#!bin/sh
# The pattern that user want to add to the files
echo "Enter the pattern of the redirect"
read value
# check if the user has... (1 Reply)
Hi All,
I have written the below script that searches for the pattern in a file and delete them if present. please can some one have a look and suggest the changes in the script.
#!bin/sh
# The pattern that user want to add to the files
echo "Enter the pattern of the redirect"
read... (4 Replies)
I have a list of pattern in a file, I want each of these pattern been searched from 4 files. I was wondering this can be done in SED / AWK.
say my 4 files to be searched are
> cat f1
abc/x(12) 1
abc/x 3
cde 2
zzz 3
fdf 4
> cat f2
fdf 4
cde 3
abc 2... (6 Replies)
Problem Statement:-
I need to search a particular `String Pattern` in around `10000 files` and find the records which contains that `particular pattern`. I can use `grep` here, but it is taking lots of time.
Below is the command I am using to search a `particular string pattern` after... (3 Replies)
Hello,
Please help me with this!! Thanks in advance!!
I have a file named file.gc with the content:
1-- Mon Sep 10 08:53:09 CDT 2012
2revoke connect from FR2261;
3delete from mkt_allow where grantee = 'FR2261';
4grant connect to FR2261 with '******';
5alter user FR2261 comment... (0 Replies)
Hi there,
Looking forward to your advice for the below:
I have a file which contains 2 paragraphs related to a particular pattern. I have to search for those paragraphs from a log file and then print a particular line from those paragraphs.
Sample:
I have one file with the fixed... (3 Replies)
in a directory, I have some files(comma seperated) and some .gz files (each .gz file contain one file which again is comma seperated).
I want to search and write the names of all those files which contain any particular value (say 1150) at any specified field position(say 10th field).
How di I do... (1 Reply)
Discussion started by: Kumar Jivi
1 Replies
LEARN ABOUT REDHAT
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)