Using pipe command between process and concatenate


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using pipe command between process and concatenate
# 1  
Old 03-07-2017
Using pipe command between process and concatenate

Dear all,

I use a pipe command to assign a variable:

Code:
[x004191a@xsnl11p317a tmp]$ v_LstStdCdhId=$(cat Bteq_Xport_GetLstStdViewToBuild__1274.txt | grep 'CD/39/AT/CDH_BV_ODS'|cut -d"/" -f1)
[x004191a@xsnl11p317a tmp]$ echo "${v_LstStdCdhId}"
43
49

My aim is to concatenate for each line of the variable v_LstStdCdhId the character "/" in order to obtain:

Code:
[x004191a@xsnl11p317a tmp]$ echo "${v_LstStdCdhId}"
43/
49/

Is it possible to get that result directly, using korn-shell syntax, in the assignment command ?

Thanks a lot,
# 2  
Old 03-07-2017
Try
Code:
VAR=$(awk -F"/" '/CD\/39\/AT\/CDH_BV_ODS/ {print $1 FS}' Bteq_Xport_GetLstStdViewToBuild__1274.txt)

Can't be tested as the input file has not been posted.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 03-07-2017
If you want to assign it all to one variable and then use that value in a loop?
Try:
Code:
while IFS=/ read v_LstStdCdhId rest
do
  if [[ $rest == *CD/39/AT/CDH_BV_ODS* ]]; then
    echo "${v_LstStdCdhId}/"
  fi
done < Bteq_Xport_GetLstStdViewToBuild__1274.txt

If you want to assign it all to one variable try:
Code:
v_LstStdCdhId=$(
  while IFS=/ read f1 rest
  do
    if [[ $rest == *CD/39/AT/CDH_BV_ODS* ]]; then
      echo "${f1}/"
    fi
  done < Bteq_Xport_GetLstStdViewToBuild__1274.txt
)


Last edited by Scrutinizer; 03-07-2017 at 03:52 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 03-08-2017
Many thanks to each of you, Rudi & Scrutinizer ... your proposals helped me a lot,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. Shell Programming and Scripting

Cannot make pipe for process substitution: Too many open files

Hi, I've came across an issue with a script I've been writing to check DHCP addresses on an Solaris system, the script has been running reasonably well, until it hit the following problem: ./sub_mon_v2: redirection error: cannot duplicate fd: Too many open files ./sub_mon_v2: cannot make... (3 Replies)
Discussion started by: CiCa
3 Replies

3. Programming

Communicate with multiple process using named pipe

how to read and write on pipes to communicate with each other? (5 Replies)
Discussion started by: nimesh
5 Replies

4. UNIX for Dummies Questions & Answers

No process to read data written to a pipe on AIX

We use SAP application cluster on AIX. Communication between 2 of its instances is failing randomly with the following error: java.net.SocketException: There is no process to read data written to a pipe. The above error causes a cluster restart if an important communication fails. Can... (0 Replies)
Discussion started by: RoshniMehta
0 Replies

5. Shell Programming and Scripting

Can I pipe stderr to another process

Hi there, I was wondering if it was possible to pipe stderr to another process. I need to eval commands given as arguments and I would like to redirect stderr to another process. I can redirect stderr to a file like this... toto:~$ command="one=1" toto:~$ eval $command 2> error toto:~$... (5 Replies)
Discussion started by: chebarbudo
5 Replies

6. AIX

Tape drive problem - no process to read data written to a pipe

Hi Everyone, The machine I'm working on is an AIX 5.3 LPAR running on a P650. oslevel -r shows 5300-08. I'm trying to take a backup to a SCSI tape drive, which has been working up until this point. I know of nothing that has changed recently to cause this problem. But when I try to take a... (0 Replies)
Discussion started by: need2bageek
0 Replies

7. Programming

Two way Pipe Process

Hi.. I am hoping someone could assist me with the pipe program I wrote below. I want to have communication from parent to child and then child to parent.. Is my logic right? int p,p1; pipe(p); pipe(p1); pid_t pid = fork(); if(pid == 0) { close(p); close(p1); dup2(p,0);... (1 Reply)
Discussion started by: therome
1 Replies

8. UNIX for Advanced & Expert Users

AIX 5.3 - There is no process to read data written to a pipe

I have the following code which works on AIX 4.3 but fails at times on AIX 5.3 with: cat: 0652-054 cannot write to output. There is no process to read data written to a pipe. validator="${validator_exe} ${validator_parms}" cmd_line="${CAT} ${data_file} | ${validator}... (6 Replies)
Discussion started by: vigsgb
6 Replies

9. Programming

sychronize process using pipe?

can pipe sychronize thread or process? because I'm trying to create 5 thread or process that can take an integer value and display it. each time a thread display the value, it has to be decrement it by 1 until the value has reach 0. The problem that I'm having is how can that integer value be... (1 Reply)
Discussion started by: saipkjai
1 Replies

10. UNIX for Dummies Questions & Answers

how to concatenate two command in one line and get the display in one screen

Hi, I would like to know , how to concatenate two command in one line and get the display in one screen for eg command 1 : ls -l /data/logs command 2 : ls -l /data/errors output shd be /data/logs /data/errors xx-xx-xx-xx abc.log xx-xx-xx-xx... (9 Replies)
Discussion started by: vasikaran
9 Replies
Login or Register to Ask a Question