bash shell scripting error need help urgently


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash shell scripting error need help urgently
# 1  
Old 04-29-2009
bash shell scripting error need help urgently

Code:
#! /bin/sh
abcd = "Hello world"
 
if [ `grep "$abcd" file1` -gt 0]
then
   echo $abcd 
fi


i got error message that
line3 : abcd: command not found
line5 : [0: command not found
line5 : [1: command not found


i have no idea why i got this message. Can some one help me ???
# 2  
Old 04-29-2009
Quote:
Originally Posted by bonosungho
Code:
#! /bin/sh
abcd = "Hello world"
 
if [ `grep "$abcd" file1` -gt 0]
then
   echo $abcd 
fi


i got error message that
line3 : abcd: command not found
line5 : [0: command not found
line5 : [1: command not found


i have no idea why i got this message. Can some one help me ???
Code:
if [ `grep -c "$abcd" file1` -gt 0];
then
   echo $abcd 
fi

cheers,
Devaraj Takhellambam
# 3  
Old 04-29-2009
watch out for spaces around [ and ]
Code:
if [ `grep "$abcd" file1` -gt 0 ]

# 4  
Old 04-29-2009
And...remove the spaces around the equal sign:

Code:
abcd="Hello world"

Regards
# 5  
Old 04-29-2009
Code:
abcd="hello world"
echo $abcd

thanks for your help!! but!!
I removed all the white spaces but i still got error message

for this command i got an error message
abcd: command not found.
# 6  
Old 04-29-2009
Maybe your shell don't like the syntax, try this:

Code:
#!/bin/sh
abcd="Hello world"

grep "$abcd" file > /dev/null

if [ $? -eq 0 ]
then
   echo "$abcd"
fi

# 7  
Old 04-29-2009
thanks everyone !! all solved !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Learn bash shell scripting

I do not know shell scripting. But at work place, I have got an in and out shell scripting task. I just need to understand a very big script. Is there any tool in which I can place the script and it can tell me the meaning of the whole script? (3 Replies)
Discussion started by: lg123
3 Replies

2. UNIX for Dummies Questions & Answers

BASH Shell Scripting: If, Then Statement

I'm having trouble trying to create a BASH shell script. I want the user to input a command "cat file_name.c" and then the shell script will delete all comments "/* */" from file_name.c else exit. So far I have this: #!/bin/bash read "cat file" // User will input command cat... (7 Replies)
Discussion started by: inkjoy00
7 Replies

3. Shell Programming and Scripting

Bash shell scripting doubt

Hello All, I am setting up a cron job, where i am calling a shell script to make few builds. I got struck at a point, need some expert inputs to proceed further. The script is categorized in 5 parts and in the last part while building software it asks for few questions like:- 1. Build mode... (4 Replies)
Discussion started by: sahil_jammu
4 Replies

4. Homework & Coursework Questions

Help with bash shell scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a bash shell script that takes as an argument a name. Then your script will ask the user for two numbers.... (15 Replies)
Discussion started by: boyboy1212
15 Replies

5. UNIX for Dummies Questions & Answers

File handling in bash shell scripting

i am new to shell scripting and stuck at one place in my program. i am reading data from one structured file and extracting some data from particular lines and then writing into the output file. In that reading input file line by line from while loop. while read line do rectype=line... (7 Replies)
Discussion started by: reeta_shri
7 Replies

6. Shell Programming and Scripting

Help need urgently for oracle cursors in k shell scripting

Hi, My Oracle Stored procedure returns sys_refcursor to shell script. I have to iterate through it in script and use those retrieved values further in my script. I am using K Shell Scrpting. Stored Procedure is: create or replace PROCEDURE p_test(job_id IN VARCHAR2, c1 OUT SYS_REFCURSOR)... (4 Replies)
Discussion started by: rajeshorpu
4 Replies

7. Shell Programming and Scripting

how to use regular expression in Bash Shell Scripting

Hi, Actually i have written one test.sh (shell program) in bash. Here i have a variables $a which stored the value package1. Now I want to write a regular expression inside the if command that "if $a variable contains letter p in the begining of the value package1 then it is coming true.... (5 Replies)
Discussion started by: sunitachoudhury
5 Replies

8. Shell Programming and Scripting

Bash shell Scripting help

wwww wwwwwwww wwwwwwwwwwwww (0 Replies)
Discussion started by: keyvan
0 Replies

9. Shell Programming and Scripting

Help!! bash shell scripting..

Can any1 please help me... i'm really lost in using bash shell scripting... and i got to hand this up on monday... please anyone teach me how to do this assignment... Please use basic things because i just learn the program only... thanks ... (1 Reply)
Discussion started by: Fr0z3n999
1 Replies

10. Shell Programming and Scripting

bash shell scripting

Hi, i am new to UNIX. I have couple of basic questions. 1. Is the syntax for BASH shell programming same in the LINUX and SUN SOLARIS operating systems? 2. I have to work on BASH shell programming in SUN SOLARIS operating system. I am going through the documentation from the following... (4 Replies)
Discussion started by: azazalis
4 Replies
Login or Register to Ask a Question