Redirect &>> problem in bash

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
jyhm
Forum Contributor
Posts: 228
Joined: Tue Dec 19, 2006 10:08 pm
Location: Connecticut, USA
Contact:

Redirect &>> problem in bash

Post by jyhm »

Code: Select all

#These work.
command -flags $variable > myfile.txt
command -flags $variable 2> myfile.txt
command -flags $variable >> myfile.txt
command -flags $variable 2>> myfile.txt
command -flags $variable &> myfile.txt

# But its choking when I do this

command -flags $variable &>> myfile.txt
Anyone have any idea? I need to be able to append both std and std err to the same file.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

command -flags $variable 1>> myfile.txt  2>&1
User avatar
jyhm
Forum Contributor
Posts: 228
Joined: Tue Dec 19, 2006 10:08 pm
Location: Connecticut, USA
Contact:

Post by jyhm »

Thanks Jenk,

You truley are a beautiful cow! :D

Is it possible to direct the result of a command into a variable? If the the result is blank I still need to have a place holder so that I can set up an array value as "N/A" or what ever.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Yes,

Code: Select all

VARIABLE=`command`
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Jenk wrote:Yes,

Code: Select all

VARIABLE=`command`
Or this:

Code: Select all

VARIABLE=$(command)
#works for arrays too
x=$(find . -name '*.*')
#or
y=$(ls -lR)
Post Reply