Hi,
This is my input file:
ali 5 usa abc
abu 4 uk bca
alan 6 brazil bac
pinky 10 utah sdc
My desired output:
pinky 10 utah sdc
alan 6 brazil bac
ali 5 usa abc
abu 4 uk bca
Based on the column two, I want to do the descending order and print out other related column at the... (3 Replies)
Can anyone please help with this? I have 2 files as given below.
If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value.
file1
abc_1 foo1@a ....
abc_1 soo2@a ...
def_2 soo2@a ....
def_2 foo1@a ........ (7 Replies)
I'm still beginner and maybe someone can help me.
I have this input:
the great warrior a, b, c
and what i want to know is, with awk, how can i detect the string with 'warrior' string on it and print the a, b, and c seperately, become like this :
Warrior Type
a
b
c
Im still very... (3 Replies)
Dear All,
I have a data file input.csv like below. (Only five column shown here for example.)
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
3,2,4,5,6
5,3,5,5,6
From this I want the below output
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
where the second column... (4 Replies)
Hi,
I have a tab delimited text file where I want to delete all rows that have the same string for column 1. How do I go about doing that? Thanks!
Example Input:
aa 1
aa 2
aa 3
bb 4
bc 5
bb 6
cd 8
Output:
bc 5
cd 8 (4 Replies)
Dear fellows, I need your help.
I'm trying to write a script to convert a single column into multiple rows.
But it need to recognize the beginning of the string and set it to its specific Column number.
Each Line (loop) begins with digit (RANGE).
At this moment it's kind of working, but it... (6 Replies)
Hello....
Pls help me (and sorry my english) :)
So
I have a file (test.txt) with 1 long line.... for example:
isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh
How to print after the "error" word the 2nd 4th 5th and 7th word??
output well be:
653 isfbisfb... (2 Replies)
Hi all,
I have searched and searched, but I have not found a solution that quite fits what I am trying to do.
I have a long list of data in three columns. Below is a sample:
1,10,8
2,12,10
3,13,12
4,14,14
5,15,16
6,16,18
Please use code tags
What I need to do is as follows: If a... (4 Replies)
Discussion started by: bleedingturnip
4 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)