LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2005, 01:02 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Problem with unix if statement


I getting the folowing error with my if then statement. What am I doing wrong?

./clearhis.sh
./clearhis.sh: line 4: syntax error near unexpected token `then'
./clearhis.sh: line 4: `then'

cat clearhis.sh
#!/bin/bash
for A in /home/*; do
if[ -f "$A/.bash_history" ]
then
>"$A/.bash_history"
fi
done
 
Old 07-28-2005, 01:07 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Put a space between if and [
 
Old 07-28-2005, 01:41 PM   #3
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Thanks!
 
Old 07-30-2005, 05:24 PM   #4
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Remember that '[' is actually the name of a program.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix Shell Programming If Statement ']['HeBroken Programming 2 12-06-2004 04:21 PM
Unix Book for Beginners (Not Linux... Unix) suse2166 General 6 11-25-2004 12:46 PM
Bad switch statement (problem in the code block?) nifflerX Linux - General 2 07-14-2004 04:45 PM
Why did you experienced users of Unix change to unix over Windows? Laptop2250 Linux - General 11 10-28-2003 12:51 PM
How to schedule unix script periodically from unix os level??? gopi_20us Programming 2 03-11-2002 07:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration