Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need advice - how to print the same last value in ksh scripts without to print param argument

for example in perl last value is $_ , but we not have this option in ksh script

example - of ksh script

 function test


 {

  ETH_PORT=eth0
  echo $ETH_PORT

  echo < what need to write in order to print last value >

   }


 test
share|improve this question
    
Please do not cross-post. –  Dennis Williamson Jan 26 '12 at 16:42

1 Answer 1

up vote 0 down vote accepted

It's not clear what behavior you want in your example. What exactly do you want the second echo to output?

I think you're confused about what $_ means in Perl. It does not refer to "the last value" but is a variable used implicitly in some cases. Refer to this page for clarification about what $_ is: http://perldoc.perl.org/perlvar.html#General-Variables

There is no "default variable" in the same meaning in ksh. A bare echo with no arguments will always just print a single linefeed. However if you want to tweak echo's behavior, you could overload it with a function.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.