hi, answer format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting hi, answer format
# 1  
Old 11-10-2011
hi, answer format

command is :
Code:
echo "BACBE03,IS38341," ; cat /home/oaydin/cha/response/gec/stp_BACBE03.txt | grep IS38341 | awk '{print $2}' ; grep -c IS38341 /home/oaydin/cha/response/gec/tx_BACBE03.txt

answer is :
Code:
BACBE03,IS38341,
ACTIVE
4

I need format :
Code:
BACBE03,IS38341,ACTIVE,4

help please
# 2  
Old 11-10-2011
Post the needed lines of stp_BACBE03.txt and tx_BACBE03.txt please. There's probably a way to do this which doesn't mean kludging another awk onto the end of this already very long pipe chain.

Also, what's your system, what's your shell?

---------- Post updated at 09:23 AM ---------- Previous update was at 09:22 AM ----------

Also, that's a useless use of cat. To save yourself some time and bother, just do grep pattern filename instead of cat filename | grep pattern
# 3  
Old 11-10-2011
Can't you do this:
Code:
tmpFile="./concatOutputs.tmp"
echo "BACBE03,IS38341," > "${tmpFile}"
grep IS38341 /home/oaydin/cha/response/gec/stp_BACBE03.txt | awk '{print $2}' >> "${tmpFile}"
grep -c IS38341 /home/oaydin/cha/response/gec/tx_BACBE03.txt >> "${tmpFile}"

tr '\n' ',' "${tmpFile}" | awk '{print substr($0, 1, length($0)-1)}'

I hope it helps!
# 4  
Old 11-10-2011
stp_BACBE03.txt line is :
Code:
IS38341   ACTIVE  0   ACTIVE

(I need of first ACTIVE)

tx_BACBE03.txt lines is :
Code:
RXOTX-4-0         IS38341   ALL   GSM900            45
RXOTX-4-1         IS38341   ALL   GSM900            45
RXOTX-4-2         IS38341   ALL   GSM900            45
RXOTX-4-3         IS38341   ALL   GSM900            45

my system is UNIX and shell is BASH

Thanks

Last edited by Scott; 11-10-2011 at 11:49 AM.. Reason: Code tags
# 5  
Old 11-10-2011
That may work, sort of, but there's probably much better ways to do it than running echo, cat, awk, two entire instances of grep, and tr.

To do anything but nail bandaids on the end though, we need to know the input data.
# 6  
Old 11-10-2011
Probably much better ways, of course there are! I just tried to give a solution based on what the OP gave us... Smilie

Last edited by felipe.vinturin; 11-10-2011 at 11:55 AM..
# 7  
Old 11-10-2011
thanks for help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I welcome all to answer my Q's

Hi everyone,, I am new to the forum...but not to Unix. I have gathered few questions from my mates who attended interviews in various companies as I have to attend one on dec 3rd for Sys admin position. Please respond with the answers you know and also help with various other interview... (2 Replies)
Discussion started by: impawan
2 Replies

2. UNIX for Dummies Questions & Answers

Please, i need an answer to this question!!

Hello!! I need some help about a question... It was asked in exams 3 years ago in Greece and nobody is certain abou the answer. Others say that the right answer is b and others say c. I found this forum and i saw that you know a lot of things about UNIX so i hope that some of you will help me.... (1 Reply)
Discussion started by: evoula_vou
1 Replies

3. UNIX for Advanced & Expert Users

hi Please try to find an answer to this

Hi Friends, I have siebel installed in one of my aix machines and while opening a file it gives below error. $ vi SmSiebelSSO.conf History file has no read permission. q Please note the file has rwxr-xr-x for oracle:dba and i am trying to open using oracle id itself which is the owner... (1 Reply)
Discussion started by: DJ2176
1 Replies

4. Shell Programming and Scripting

help me to answer this

Hello everyone I update my question. Thanks for your reply joeyg If I type the last command and send to a text file. I get this last >usuarios.txt root pts/0 160.40.35.277 May 22 11:08 still logged in. root pts/0 alopez02 May 22 09:23 - 10:11 (00:47) root pts/0 160.40.35.277 May 20... (0 Replies)
Discussion started by: lo-lp-kl
0 Replies

5. UNIX for Dummies Questions & Answers

Answer them if u can...

Try to answer these questions on Unix: 1.what will be the segment() function do? 2.How Unix is more powerful than Windows? 3.Where ownership details will be stored of a particular file in Unix? 4.State different uses of ^ symbol in regular expressions. 5.What does export command used for?... (5 Replies)
Discussion started by: dreambig
5 Replies

6. Shell Programming and Scripting

Is sed the answer?

Hey, I am very new to scripting and could use a bit of help. I have a situation where I have an ascii file and I want to delete all lines beneath a particular string. EXAMPLE: The contents of a file named example.txt looks like the following: JANUARY FEBRUARY MARCH APRIL MAY JUNE... (7 Replies)
Discussion started by: LaLonde
7 Replies

7. Solaris

Can anybody answer this.....

Hi i am trying the threads concept in unix environment using C... but i am getting error of "wait_fd: Couldn't find procinfo for fd 24"... what does this error mean..... help me in solving this issue... Thanks in advance shivamasam (3 Replies)
Discussion started by: shivamasam
3 Replies

8. Programming

can any one answer ????

Q.1 Diffrence between terminal and pseudo-terminal ? Q.2 What is terminal login ? What is a netwok Login ? Q.3 What is meant by baud rate of a terminal ? Q.4 which structure is used for job control in Unix/Linux ?and where these structure are means in which directory ? (2 Replies)
Discussion started by: mobile01
2 Replies

9. UNIX for Dummies Questions & Answers

urgent answer these please

Hi, Please explain what does '$*' mean. what does the command cd /~abc do, especially what does '~' mean? cheers. (1 Reply)
Discussion started by: uni_ajay_r
1 Replies

10. UNIX for Dummies Questions & Answers

already found the answer

Hi folks, I Got a little question here, When i try to start a telnet session to my unix server, the unix server states the following message: telnetd: All network ports in use. Connection closed I know it has something to do with pseudo tty's? I've tried to search the... (3 Replies)
Discussion started by: Erik Rooijmans
3 Replies
Login or Register to Ask a Question