Sponsored Content
Full Discussion: Echo output from command
Top Forums Shell Programming and Scripting Echo output from command Post 302749471 by Don Cragun on Friday 28th of December 2012 11:50:08 AM
Old 12-28-2012
If I understand what you're trying to do, the following should be the syntax you need:
Code:
if [ "$(ls -l|wc -l)" -gt 2 ]
then
        echo 'error'
else
        echo '$'
fi

This won't display the output from the ls command. If you want to display the output from the ls command, change the
Code:
"$(ls -l|wc -l)"

to:
Code:
"$(ls -l|tee /dev/tty|wc -l)"

I don't understand why you want the echo "$"; it is the default normal user shell prompt and may confuse users if it looks like your script produces two shell prompts.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Store output and Echo

I will admit I am a newbie but I am trying to write some simple scripts Situation: I have a list of IP Addresses that I want to once or 2 times a day store the average ping response time in a database (mysql) I am part way there but not all the way there I have the following cat ./slow... (2 Replies)
Discussion started by: meyerder
2 Replies

2. Shell Programming and Scripting

piping output to echo

Hi, I was wondering why ls * | echo does not print the contents of the directory to the screen? The way I see it, ls * returns a whole lot of information, and then we pipe all this info to echo, so surely it should all come to our screen! Is there a serious flaw in my understanding? ... (3 Replies)
Discussion started by: A1977
3 Replies

3. UNIX for Dummies Questions & Answers

What is the output of echo *

Hi all, Kindly let me know the output of echo * command. (4 Replies)
Discussion started by: shailja
4 Replies

4. Shell Programming and Scripting

weird echo output?

#!/bin/bash INPUT=$1 if then INPUT=0$1 TRACKNUMBER=$INPUT fi TRACKNUMBER=$INPUT echo "Track Number:" $TRACKNUMBER if then echo "File Does Not Exist!: split-track"${TRACKNUMBER}".wav" exit 0 fi CUEFILE="$2" (6 Replies)
Discussion started by: TinCanFury
6 Replies

5. Shell Programming and Scripting

Echo and a command's output on the same line

Hello, I'm writing some bash scripts and I'm trying to get an echo command and the output of another command to display on the same line. For example: I want to run echo "Operating System: " unameand have it displayed as Operating System: Darwin Thanks for your help! (7 Replies)
Discussion started by: codyhazelwood
7 Replies

6. UNIX for Dummies Questions & Answers

Format output from "echo" command

Hi, I have written a BASH shell script that contains a lot of "echo" commands to notify the user about what's going on. The script generates a log file that contains a copy of what is seen in the terminal. The echo statements are generally verbose, and thus extend out for quite a ways on one... (2 Replies)
Discussion started by: msb65
2 Replies

7. Shell Programming and Scripting

problem with suppressed output to file using echo and tee command

Hi, When I run the following command in terminal it works. The string TEST is appended to a file silently. echo TEST | tee -a file.txt &>/dev/null However, when I paste this same line to a file, say shell1.sh, and use bourne shell . I run this file in terminal, ./shell1.sh. However I... (1 Reply)
Discussion started by: shahanali
1 Replies

8. Shell Programming and Scripting

echo two command output in the same line

Hi, I try to write script and echo two command at the same line . echo "A" echo "B" How can I pipe above two command at the same line in text file . So, in the output text file , you can see below ??? A B not A B Any sugggestion ??? (4 Replies)
Discussion started by: chuikingman
4 Replies

9. Shell Programming and Scripting

Need help in echo output

Hi All, I have code to get the UUID and capacity for the LUN from CX -arry. I need the output in this format LUN Number UUID Space in MB LUN 238 60:06:01:60:C2:56:11:00:28:36:67:59:11:04:DE:11 122880 But Now iam getting this... (3 Replies)
Discussion started by: ranjancom2000
3 Replies

10. Shell Programming and Scripting

How to echo output of a UNIX command (like ls -l ) using shell script.?

How do i echo the output of a unix command using shell script??? Like: echo /etc/ ls -l (2 Replies)
Discussion started by: sunny2802
2 Replies
Devel::Refcount(3pm)					User Contributed Perl Documentation				      Devel::Refcount(3pm)

NAME
"Devel::Refcount" - obtain the REFCNT value of a referent SYNOPSIS
use Devel::Refcount qw( refcount ); my $anon = []; print "Anon ARRAY $anon has " . refcount($anon) . " reference "; my $otherref = $anon; print "Anon ARRAY $anon now has " . refcount($anon) . " references "; DESCRIPTION
This module provides a single function which obtains the reference count of the object being pointed to by the passed reference value. FUNCTIONS
$count = refcount($ref) Returns the reference count of the object being pointed to by $ref. COMPARISON WITH SvREFCNT This function differs from "Devel::Peek::SvREFCNT" in that SvREFCNT() gives the reference count of the SV object itself that it is passed, whereas refcount() gives the count of the object being pointed to. This allows it to give the count of any referent (i.e. ARRAY, HASH, CODE, GLOB and Regexp types) as well. Consider the following example program: use Devel::Peek qw( SvREFCNT ); use Devel::Refcount qw( refcount ); sub printcount { my $name = shift; printf "%30s has SvREFCNT=%d, refcount=%d ", $name, SvREFCNT($_[0]), refcount($_[0]); } my $var = []; printcount 'Initially, $var', $var; my $othervar = $var; printcount 'Before CODE ref, $var', $var; printcount '$othervar', $othervar; my $code = sub { undef $var }; printcount 'After CODE ref, $var', $var; printcount '$othervar', $othervar; This produces the output Initially, $var has SvREFCNT=1, refcount=1 Before CODE ref, $var has SvREFCNT=1, refcount=2 $othervar has SvREFCNT=1, refcount=2 After CODE ref, $var has SvREFCNT=2, refcount=2 $othervar has SvREFCNT=1, refcount=2 Here, we see that SvREFCNT() counts the number of references to the SV object passed in as the scalar value - the $var or $othervar respectively, whereas refcount() counts the number of reference values that point to the referent object - the anonymous ARRAY in this case. Before the CODE reference is constructed, both $var and $othervar have SvREFCNT() of 1, as they exist only in the current lexical pad. The anonymous ARRAY has a refcount() of 2, because both $var and $othervar store a reference to it. After the CODE reference is constructed, the $var variable now has an SvREFCNT() of 2, because it also appears in the lexical pad for the new anonymous CODE block. PURE-PERL FALLBACK An XS implementation of this function is provided, and is used by default. If the XS library cannot be loaded, a fallback implementation in pure perl using the "B" module is used instead. This will behave identically, but is much slower. Rate pp xs pp 225985/s -- -66% xs 669570/s 196% -- SEE ALSO
o Test::Refcount - assert reference counts on objects AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2011-11-15 Devel::Refcount(3pm)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy