Skip to main content
deleted 102 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237

This gives me an error that says too many arguments:

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

This gives me an error that says too many arguments:

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

This gives me an error that says too many arguments:

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation?

deleted 2 characters in body
Source Link
muru
  • 77.9k
  • 16
  • 212
  • 318

This gives me an error that says too many arguments:

if [ $( file -b $i ) ] == "directory" ]

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

This gives me an error that says too many arguments:

if [ $( file -b $i ) ] == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

This gives me an error that says too many arguments:

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

Tweeted twitter.com/StackUnix/status/820532013962850307
OP's edit made the first point of the accepted answer invalid. Also, improved title
Source Link

Bash Why does itdoesn't the conditional work when I assign an output touse it directly without a variable?

This gives me an error that says too many arguments:

if [ $( file -b $i ) ] == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

Bash Why does it work when I assign an output to a variable?

This gives me an error that says too many arguments:

if [ $( file -b $i ) == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

Why doesn't the conditional work when I use it directly without a variable?

This gives me an error that says too many arguments:

if [ $( file -b $i ) ] == "directory" ]

But when I tried this

name=$( file -b $i )
if [ name == "directory" ]

It seems to work just fine.

Can someone explain this or point out in the docs an explanation? I am new to bash but from the standpoint of other programming languages this doesn't make any sense.

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
Loading
removed extra ]
Source Link
Loading
Source Link
Loading