The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
VI Substitution problem gravy26 AIX 7 02-13-2008 04:12 PM
Bash: bad substitution problem...pls help! xfouxs UNIX for Dummies Questions & Answers 1 11-23-2007 05:48 PM
Define an alias with an embeded awk command ?? jfortes Shell Programming and Scripting 5 06-05-2007 01:03 PM
Substitution problem. er_ashu Shell Programming and Scripting 3 04-03-2007 07:48 AM
Substitution of last command ghazi Shell Programming and Scripting 6 01-16-2005 07:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2008
wrl wrl is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 7
problem in embeded command substitution

$ echo $(tty|sed 's#/[a-z]*/##')
pts/0
$ who | grep $(tty|sed 's#/[a-z]*/##')
grep: 0652-033 Cannot open 0551-011.
grep: 0652-033 Cannot open Standard.
grep: 0652-033 Cannot open input.
grep: 0652-033 Cannot open is.
grep: 0652-033 Cannot open not.
grep: 0652-033 Cannot open a.
grep: 0652-033 Cannot open tty..
$


does anybody know why the command substitution gots error here?
does any rule forbid the command substitution in pipeline?
thanks in advance!
  #2 (permalink)  
Old 08-07-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Because it's in a pipeline, tty is not connected to your terminal.

You can work around it by running tty first, and then grepping.

Code:
tty=$(tty | sed 's#/[a-z]*/##')
who | grep "$tty"
  #3 (permalink)  
Old 08-07-2008
wrl wrl is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 7
got it, thanks!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0