Variable unexpectedly blank after piped loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Variable unexpectedly blank after piped loop
# 8  
Old 10-19-2018
Hi RudiC,
You may indeed object. But, you need a very recent version of bash to get that shopt option. On the latest release of macOS, the bash installed is version 3.2.57 which produces the following when trying to set that option:
Code:
bash-3.2$ shopt -s lastpipe
bash: shopt: lastpipe: invalid shell option name
bash-3.2$

and a man bash | grep lastpipe produces no output.
This User Gave Thanks to Don Cragun For This Post:
# 9  
Old 10-20-2018
Yes - I should have mentioned my bash version: 4.4.19(1)-release
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use cut output as variable piped awk command

Hi, I would like use the output of my cut command as a variable in my following awk command. Here's what I've written. cut -f1 info.txt | awk -v i=xargs -F'' '{if($6 == $i) print $20}' summary.txt Where obviously the 'xargs' doesn't do what I want. How can I pass my cut result to my awk... (3 Replies)
Discussion started by: heyooo
3 Replies

2. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

3. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

4. Shell Programming and Scripting

append blank spaces at the end of a variable string

Hello, could you please help with this one. I have an input file like this: 123,4567,89000 123456789,9876543,12 and for the output I need strings to be with the fixed length, let's say 15, and if the string is -lt 15 to be populated with blanks at the end until it reach 15, like this: 123 ,4567... (1 Reply)
Discussion started by: apenkov
1 Replies

5. Shell Programming and Scripting

ignore blank lines in while loop

Hi, i am having one text file it contains some blank lines and i want to ignore that blank lines . #! /bin/bash clear rdCount=0; while read myline do echo $myline let rdCount=$rdCount+1 done < ps.txt echo "Total line=$rdCount" and ps .txt contains the data- (17 Replies)
Discussion started by: aish11
17 Replies

6. UNIX for Dummies Questions & Answers

While loop seems to exit when blank line is met

Hello everyone! I am having an issue with a script I am trying to create. I have an input file (named sort_$1.txt) like: aaaa bbbb cccc dddd eeee and I process it with the following code: while read -r EachLine2 do (11 Replies)
Discussion started by: haaru
11 Replies

7. Shell Programming and Scripting

KSH variable containing piped commands

Hi, I am trying to execute a bunch of piped command which are stored in a variable, but only one command executed at a time, and rest of the pipes, commands and their arguments are considered as argument to the very first command. Can you please help me in this? bash-2.05$ cat test.sh... (1 Reply)
Discussion started by: prashant.ladha
1 Replies

8. Shell Programming and Scripting

Unix mail with blank line on variable

I am testing a ksh script for email. In the subject/content of the mail there is some dynamic variables like date and charges. However these variables occupied the entire line erase other in that particular line For e.g. there is a mail message: This mail is intent... Your total... (2 Replies)
Discussion started by: balaji.rengaraj
2 Replies

9. Shell Programming and Scripting

how to check the variable values is blank

HI , I have to check the values of variable is blank or not. exm : ###test test1 var=`cate filename | head -1 | cut -c1-3` I need to check the first three character of 1st line . if it is blank .then exit or we need to process . Thanks in advance . (2 Replies)
Discussion started by: julirani
2 Replies

10. Shell Programming and Scripting

[bash] Check if variable is set or blank

Hello guys. In my script, i have the following code: echo "The tarfile contains these directorys" tar -tf file.tar > tarlist.txt cat tarlist | awk -F/ '{print $1 "/" $2}' | nl echo "Enter path of the directory you want to extract or just press enter to extract everything: " read path... (1 Reply)
Discussion started by: noratx
1 Replies
Login or Register to Ask a Question