Hi,
I should read a number situated just after "= " symbole in a line from a file and put it in a variable.
the line in file is :
number of transaction=7
and I should put 7 in a variable (7 or other values), then
read the file :
And then how to select just the number after = symbole :
If the text you want to analyze is in a variable already:
This produces the value in othervar with anything up to the first equals sign removed.
If it's coming from a file which contains a single line:
There's a myriad different ways to split a file on a particular separator but cut is very simple and easy to understand. You could also do this with sed, awk, perl, or even grep (if you are a bit clever, and trust there to be exactly one equals sign in the file).
If there are multiple lines and you want the one with "number of transactions", try awk or sed:
Note that the backquote characters are "grave" ones (ASCII 96), not regular apostrophes.
Last edited by era; 04-23-2008 at 12:56 PM..
Reason: awk example, too
You seem to have replaced the final backquote with a regular apostrophe; it's probably better if you copy+paste the code from above in order to get the punctuation right.
Also, I carelessly put in "transactions" in plural; you will need to drop the final s. Sorry about that.
Hi experts,
I am using KSH and I am need to display file with number in front of file names and user can select it by entering the number.
I am trying to use following command to display list with numbers. but I do not know how to capture number and identify what file it is to be used for... (5 Replies)
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Hi Power User,
I'm trying to compute this kind of text file format:
file1:
jakarta 100 150
jakarta 170 210
beijing 220 250
beijing 260 280
beijing 290 320
new_york 330 350
new_york 370 420
tokyo 430 470
tokyo 480 ... (2 Replies)
I would like to print the number of records of 2 files, and divide the two numbers
awk '{print NR}' file1 > output1
awk '{print NR}' file2 > output2
paste output1 output2 > output
awl '{print $1/$2}' output > output_2
is there a faster way? (8 Replies)
Dear Perl users,
I need your help to solve my problem below.
I want to print the sequence number without missing number within the range.
E.g. my sequence number :
1 2 3 4 5 6 7 8 11 12 13 14
my desired output:
1 -8 , 11-14
my code below but still problem with the result:
1 - 14
1 -... (2 Replies)
I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as
name1:name2:name3:1
when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count
The input file:
21 2341 A
21 2341 A
21 2341 A
21 2341 C
21 2341 C
21 2341 C
21 2341 C
21 4567 A
21 4567 A
21 4567 C
... (6 Replies)
hi experts(novice people can stay away as it is no child's game),
i am developing a script which works like recycle bin of windows.
the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)