Shell Problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Problem
# 8  
Old 11-21-2006
Quote:
Originally Posted by grial
So strange... OK, let's make a check list Smilie :
* ls -l /usr/bin/grep (or wherever it is)
* whoami
* file /usr/bin/grep (or wherever it is)
* try with awk: ls -l | awk '/Nov 3/ {print}'
* And of course, as vino says, any error text would be appreciated.
And show us the results, please.
Regards.
I do find this on the prompt ..( it doesnt throw any error message )
unix > ls
a.sh abc.txt
b.sh prod.tar
c.sh leon.exe

after this I am using .............

unix > ls -l | grep *.sh
unix >

( only prompt is returned ...no error message nothing )
( I have relogged the unix box ... but this simple command doesn't work )

should have anything corrupted ?
or has executing any other command has disabled grep command ...No clue
# 9  
Old 11-21-2006
Have you tryed everything I suggested? One more thing to add to the list:
* echo $?
just after the command.

Without all that info, I'm afraid I won't be able to help you...
# 10  
Old 11-21-2006
Quote:
Originally Posted by grial
Have you tryed everything I suggested? One more thing to add to the list:
* echo $?
just after the command.

Without all that info, I'm afraid I won't be able to help you...
ls -l
echo $?
whoami ..all are giving proper output

if i use
whoami | grep "mar" ( it gives proper o/p )

but when I use ls -l | grep *.sh .............its not working
# 11  
Old 11-21-2006
Try

Code:
ls | grep ".sh"

I created files by that name and got the output
Quote:
> ls | grep ".sh"
a.sh
b.sh
c.sh

* is a special character for grep(used in regular expressions)
# 12  
Old 11-21-2006
Quote:
Originally Posted by vish_indian
Try

Code:
ls | grep ".sh"

I created files by that name and got the output


* is a special character for grep(used in regular expressions)
Thanks Vish ....
It has worked .....

but why it happens ...
If I use * ... then it should consider it as 0 or more occurances of a character ...
# 13  
Old 11-21-2006
Quote:
Originally Posted by dhananjayk
ls -l
echo $?
whoami ..all are giving proper output
I just wanted to see it... OK, I give up: I will believe in what you say and this is my conclusion:
- The grep command si working perfectly.
# 14  
Old 11-21-2006
From what I know * is 0 or more occurrence of the previous character. Since there is no previous character in expression *.sh , it fails. Not sure which character it assumes there.

Try
Code:
 grep .*\.sh

it works. This checks for any character(s) followed by .sh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

shell problem

this picture for print You didn't do the question. Go back. if $1 = 0 but until now it give me this message what i should be do ? http://img717.imageshack.us/img717/6137/eeevb.jpg (2 Replies)
Discussion started by: NeeZaaR
2 Replies

2. Shell Programming and Scripting

shell problem

problem: I give the source of a c program.. is required to indicate how many times is called each function defined in the program and line number there is a call. let's say i have lab2.c: float dist(int *a,int *b,int n){ int i=0; double d=0; for (i=1;i<=n;i++){ d+=pow((a-b),2); }... (4 Replies)
Discussion started by: sherpeledenis
4 Replies

3. Shell Programming and Scripting

Problem in shell script

hi...i create a script which reads data from file and compare that the data which is entered by me through keyboard...i can easily read first two contents of file..i am facing the problem to read other contents.. structure of my file is username:password:username1:password1.......and so on ... (1 Reply)
Discussion started by: shubhig15
1 Replies

4. Shell Programming and Scripting

shell problem

Hello! Can you please help me on a lab at school: I have to to write a shell program which reads all .C files from the current directory and prints for each file how many '#define' directives it has and for each macro defined how many times is it used in that file. Can you suggest how can i... (1 Reply)
Discussion started by: dark_knight
1 Replies

5. Shell Programming and Scripting

problem with if in shell

Hi, My sheel script has below statement: if; then When I run iam getting the below error: -bash: syntax error near unexpected token `then' What is wrong with that statement: Plz help me. (2 Replies)
Discussion started by: pradeep_script
2 Replies

6. Shell Programming and Scripting

Problem in shell

hi, can any one tell a solution for the following : I want to append 10 spaces and a string say "ok" to 12 digit number which is stored in a varialbe & display using shell script. (1 Reply)
Discussion started by: Sandeep Kale
1 Replies

7. UNIX for Dummies Questions & Answers

shell problem

What are the different type of shell available in UNIX and how to change the shell? just this 2 question pls help mi (4 Replies)
Discussion started by: yeah016
4 Replies

8. UNIX for Advanced & Expert Users

Shell Problem

Dear Members; I changed ,by mistake ,the root shell in /etc/passwd and logged out. Thereafter, I can no more have a prompt when trynig to log in as root. How to solve this pb ? Regards :confused: (8 Replies)
Discussion started by: oss
8 Replies

9. UNIX for Dummies Questions & Answers

Shell Problem.

Hello and Good day to all. Im having a problem here and would like to know if there is any solution that could overcome my problem. I have changed from bash to csh (c-shell) yesterday on my Linux 7.2. When i do $echo $SHELL i can see the output /bin/csh which means ihave succesfully landed on... (4 Replies)
Discussion started by: ###1tomato
4 Replies

10. UNIX for Dummies Questions & Answers

shell problem

&& set -x && echo "enter tablespace_end_backup" >&2 Can you tell me what's mean above? thanx (1 Reply)
Discussion started by: Lee
1 Replies
Login or Register to Ask a Question