Visit The New, Modern Unix Linux Community


Simple grep is not working properly on busybox


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple grep is not working properly on busybox
# 1  
Simple grep is not working properly on busybox

Hi,

I'm trying to write shell scripts on busybox bash on windows and grep is not working for simple regular expression like

Code:
$ grep FEN *
bash: grep: Invalid argument

but the same grep works fine if use the single file instead of asterisk

Code:
$ grep FEN test
[FEN "abc"]
$

Am I doing something wrong here or is it a bug with busybox? If yes, Is there any bug-free (or latest version) of busybox? Is there any best portable alternative to cygwin?

cygwin is a perfect choice for me but I'm not supposed to install anything on my current laptop. This portable cygwin doesn't seem to be active. Is this portable cygwin of any good?

Please advise,
Thanks

Last edited by prvnrk; 07-21-2014 at 08:52 PM..
# 2  
What does the command:
Code:
printf "'%s'\n" *

do in that directory?
# 3  
Quote:
Originally Posted by Don Cragun
What does the command:
Code:
printf "'%s'\n" *

do in that directory?
Thanks for the reply.

It displays list of all the files with each file name between 2 single quotes '

Code:
$ printf "'%s'\n" *
'sample_test_50_diag_011.pgn'
'sample_50_diag_012.pgn'
'test'
$

# 4  
In the standards, the behavior of grep is only defined when the operands are text files. One use of the .pgn extension is for Portable Game Notation files, but the names you showed us don't sound like game status files. If these are some kind of (binary) graphics files, your version of grep may be rejecting them.

Did you just try:
Code:
grep FEN test

or did your also try one or both of:
Code:
grep FEN sample_test_50_diag_011.pgn
grep FEN sample_50_diag_012.pgn

?
# 5  
How are you managing to mix bash and Busybox grep? The shell in Busybox is not Bash, it is ash.
# 6  
Quote:
Originally Posted by Don Cragun
If these are some kind of (binary) graphics files, your version of grep may be rejecting them.

Did you just try:
Code:
grep FEN test

or did your also try one or both of:
Code:
grep FEN sample_test_50_diag_011.pgn
grep FEN sample_50_diag_012.pgn

?
All these are text files only.

Code:
$ grep FEN sample_test_50_diag_011.pgn
[FEN "r4brk/5p1p/2bp1P2/p3p2N/1pq1P3/5N1Q/PPP4P/1K1RR3 w - - 0 1"]
$ grep FEN sample_50_diag_012.pgn
[FEN "2r1r1k1/1p4bp/p2p1qp1/1n1P4/2P1B2P/1N1Q4/PP2R3/1K5R b - - 0 1"]
$

Quote:
Originally Posted by fpmurphy
How are you managing to mix bash and Busybox grep? The shell in Busybox is not Bash, it is ash.
I don't know. I run busybox.exe bash at windows command prompt to get the shell

and this shows me that its bash, correct me pls if I'm wrong

Code:
$ echo $0
bash


Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #65
Difficulty: Easy
In the TCP/IP model, end-to-end connectivity is provided from host-to-host in the transport layer.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expansion not working properly

I'm using an Ubuntu machine and expansion is not working properly. What would cause this? Do I need to check for any particular bash packages? $ ipcs -m | grep $USER | awk '{printf "%s ",$2}' $ ipcs -m | grep UNF | awk '{printf "%s ",$2}' 294912 1048577 425986 688131 786436 1245189... (14 Replies)
Discussion started by: cokedude
14 Replies

2. Web Development

CGI not working with httpd server on busybox 1.15.0 on ltib Linux 2.6.34 (404 page not found)

I have some industrial ARM linux board with 2.6.34 Linux on it with Busybox v1.15.0. The https.conf is located in /etc/ and contains: H:/root/web In the www directory I also have 'cgi-bin' folder with chmod 777 and in that folder a file called 'testcgi'. Now I start the server with... (1 Reply)
Discussion started by: Roboserg
1 Replies

3. Linux

rexec not working properly

Hi, I am trying to enable rexec to automate certain tasks(it has to be rexec, not ssh or any other due to the system environment), so after switching to linux, I followed the certain instructions that were laid out in the web. My operating system is fedora 17, so I first installed the... (1 Reply)
Discussion started by: wringer
1 Replies

4. Shell Programming and Scripting

ash busybox read command not working inside function....

I have a script that has to execute a read command in a function, this is in an ash busybox. The code is... trapcatch () { echo "Ctl-c Detected, what do you want to do?" echo "Please choose the number of one of the following options" echo "1. Jump past this Set" echo "2. Exit... (8 Replies)
Discussion started by: tesser
8 Replies

5. Shell Programming and Scripting

simple grep is not working for me

Hi, On the log Netscape log, I need to grep for 500 error. I am doing that but I also get 1500 in that same log. cat access |grep "500" Results: "GET /css/RBR.css HTTP/1.1" 200 15000 304 - - - 399 639 523 164 0 This not what I need... Please advice. (4 Replies)
Discussion started by: samnyc
4 Replies

6. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

7. HP-UX

FC card not working properly

Hi I've a problem with Hp-ux 11.11 9000/800/rp3440 system. Already the software for driver & its patch are loaded for HBA Fibrechannel card, but still the fibrechannel card is showing the status "Unclaimed" . What will be reason for this? How to get the status "Claimed" ? Pl. help me out.... (4 Replies)
Discussion started by: Mike1234
4 Replies

8. UNIX for Dummies Questions & Answers

Telnet is not working properly

telnet at my system is behaving stange. Some times I am able to telnet to other machines but sometimes it stop doing that. Then i have to reboot the machine and most of the time (not 100%) it works. SImilar is the case with SSH. Sometime it works , some time it don't. i am new to Unix and I do not... (1 Reply)
Discussion started by: deepak_pathania
1 Replies

9. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\> "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

10. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies

Featured Tech Videos