my ksh script collects a procstack trace for a particular pid and then greps it by a transaction id to find out the pthread ID:
---------- tid# 1876087 (pthread ID: 4466) ----------
So the pthread ID I want is 4466 in this case, and it is assighed to the variable $pthread. This works fine so far.
After this point, I need to read the first line of a few files whose names are composed by several variables in $HEAD_FILE and a number that it reads from file task2. This currently contains:
32888
So HEAD_FILE will be /logs/eComm_esn_32888.log and the loop will only run once. The first line of this file contains:
1021 2010-03-02 17:06:17 0000-00-00 00:00:00 +0100 00000000 001 003f 0001 09 eComm 32888 893162 4466 /logs/eComm_32888.log 7.8.2.8 [19237] ESN
I want to set a condition that if field number 15 is equal to the pthread ID (4466) it should print the whole line. Otherwise not. AWK has difficulty in reading the first few characters, so I have used sed to replace them with "nothing" (8 dots).
This makes 4466 be in the $14th position now so I can change the condition.
Here´s the relevant part of the script:
========
=======
Running this as it is gives me the following:
=======
So it echoes the value of HEAD_FILE as it understands it now, and the number I am interested in is in 14th position, but I don´t know how to get around the 'cannot open' error to make my condition work.
I only want the 1st line of the file read in the loop which contains the number matching the value of $pthread, obtained a little earlier (4466). Does anyone have any ideas of what I am doing wrong? I think I´ve been staring at this too long..
I have tested that if the number is matched it prints, and if it doesn´t, then it doesn´t print.
However, as the 4466 number could change on each run of the script, I have replaced the number for variable $pthread, which is defined a few lines up. Now this line gives me errors:
My line is now:
I have tried ${pthread} also, but with the same error.. (
T.
Last edited by Scott; 03-06-2010 at 07:02 AM..
Reason: Code tags please...
I would never have guessed it cos I can´t see why I have to define and use another variable to compare values when pthread was already defined....I have so much to learn yet.. /
Hi dears
i use bash shell
i have INPUT.txt
like this
number of columns different in one
some row have 12 , some 11 columns
see last column
INPUT.txt
CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic
63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Hi dears
i have text file like this:
INPUT.txt
001_1_173 j nuh ]az
001_1_174 j ]esma. nuh ]/.xori
.
.
. and have another text
like this
TABLE.txt
j j
nuh word1... (6 Replies)
i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
data.txt:
hellohellohello
mellomello1mello
tellotellotellotello
bellobellowbellow
vellow
My attempts:
egrep ".*mello1\n.*bellow" data.txt
awk '/.*mello1.*\nbellow/' data.txt
how can i search for patterns that are on different lines using simple egrep or awk?
i only want the... (7 Replies)
Hi
I have a large txt file on my AIX server and I need to replace some text using two other files. So filename1 has about 500 lines similar to:
txtcode SYStem100
I have the string I want to change in string2 and the new stringname in string3. Does anyone know a way of doing this? I have... (1 Reply)
Hi friends,
I am pretty new to shell scripting, please help me in this Scenario.
for example, If I have one file called input.txt
once I run the script,
1.It has to delete the old input.txt and create the new input.txt (if old input.txt is not there, no offence, just it has to create a... (2 Replies)
I have a file with a single filename in it, which I want to assign to a BASH variable, so I've been trying:
c=$(head -1 somefile)
echo $c
which outputs correctly, but them when I do
...
somecommand $c
it says it can't find the file, is that because it's grabbing the whole line, and... (5 Replies)
Hi,
I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes..
i wanna attach a text file and send to a mail id..used the following code :
uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com
it works... (2 Replies)
I need to take the totals from my script and input them into a excel spreadsheet. Right now, I just copy and paste. Is there an easier way?
3906
is the total jobs in ABEND state
4005
is the total jobs in SUCC state
1050
is the total jobs in HOLD state (1 Reply)