Strange problem with grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange problem with grep
# 1  
Old 09-18-2009
Strange problem with grep

Hi All,
I got strucked with some strange problem, I wrote a command for removing line which has '/' character . command is grep -v "^/" $filename > directory/outfile.txt. This command is working well at command prompt but when I put this command in a file file2.ksh and calling from file1.ksh , the line which has '/' in text file is not deleted, instead '/' is replaced with "_" but the same command is working well at command prompt. I don't understand why this problem is existing. Kindly suggest me .

Thanks
# 2  
Old 09-18-2009
The regex "^/" gives lines that begin with a slash, try :

Code:
grep -v "/"

# 3  
Old 09-18-2009
Please show us a few example lines of the records you wish to adjust, but with any control codes made visible with this command:

Code:
sed -n l filename

I'm guessing that your file contains control codes which are appearing on the screen as say "^/" .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strange Script behaviour with Grep

Here is my script LOGDATE=`date '+%Y-%m-%d %k:%M' | cut -c1-15` echo $LOGDATE echo "grep '$LOGDATE' /tmp/logs/vel.log >10min_log" grep '$LOGDATE' /tmp/logs/vel.log>10min_log grep '$LOGDATE' /tmp/logs/vel.logHere is the output of the script -rw-r--r-- 1 wluser wluser 0 May 3... (7 Replies)
Discussion started by: mohtashims
7 Replies

2. Shell Programming and Scripting

Strange behavior of grep

Hi All, I am facing a strange problem while grepping for a process. Here is the small script that i have written. It will look for any process running with the parameter passed to the script. If no process is running it should print appropriate message. $ cat t.ksh #!/bin/ksh set -x ... (9 Replies)
Discussion started by: veeresh_15
9 Replies

3. UNIX for Dummies Questions & Answers

Strange behaviour of grep in SunOS

Hi I ahve 2 files with below content: cat file1 FILE3 test1 test2 cat file2 file3 ghg test1 test2 i want to use file1 as pattern file and find out the missing strings in file2.(i.e ghg in this case regardless of c ase) I have tried: grep -i -v -f /path/file1 /path/file2 (6 Replies)
Discussion started by: pandeesh
6 Replies

4. Shell Programming and Scripting

Grep a file that may contain strange characters

Hello unix users :) I am trying to grep a string from a file that both the file and the string may have characters in them that are quite... strange, like würzburger. Well, bash reads this as W%C3%BCrzburger For example, if i do wget W%C3%BCrzburger the output is: --2012-01-08... (2 Replies)
Discussion started by: hakermania
2 Replies

5. UNIX for Dummies Questions & Answers

Strange error: grep does not read from file

I have two files file1.txt angie mary susan file2.txt angie blond mary brunnet susan red christine blackI want to get this output angie blond mary brunnet susan redI write grep --file=file1.txt file2.txtand i get no results i also wrote cat file1.txt|while read line... (19 Replies)
Discussion started by: FelipeAd
19 Replies

6. Shell Programming and Scripting

Strange Problem

Hi All, I am encountering an unexpected problem while running my process, using daemon placed in /etc/init.d/. I have a process that is opening shared library using dlopen. When I run my process on the command line, it is able to open the library. But when I used daemon to run my process, I... (0 Replies)
Discussion started by: qwerty-1
0 Replies

7. UNIX for Dummies Questions & Answers

Strange output from grep

Hi, I am getting different output for grep depending which directory I am in. The following is a transcript of my session, I am using egrep but have also used grep -E. The directory names have been changed for security: $pwd /dir1/dir2/dir3/dir4 $echo 000000 |egrep -v $echo $? 1 $cd ..... (10 Replies)
Discussion started by: Bab00shka
10 Replies

8. Linux

very strange problem

I have installed Fedora Core on a Toshiba Satellite Pro4600 laptop recently I have experienced a rather mysterious problem if I touch anything specially the keyboard or mouse I see this stuff “67yujhnmyyy” straight away some time it won't stop for while like this... (5 Replies)
Discussion started by: kemobyte
5 Replies

9. UNIX for Dummies Questions & Answers

strange...problem

Hi.. Some of my application were not running properly due to lack of virtual memory.....so wht i did add one free harddisk as swap file system...and increased the swap memory.. But since than my root file system is showing 100% full thr is no space left...is thr any link between these two..... (1 Reply)
Discussion started by: Prafulla
1 Replies

10. UNIX for Dummies Questions & Answers

Strange Problem

I did an installation of Redhat 7.1 and it seem to install smoothly. I go and reboot and I get the following message: "INIT: Id "x" respawing too fast: disabled for 5 minutes" The screen flashes 4 times every 10 seconds or so. I can't seem to figure why this does this. It might be a simple... (2 Replies)
Discussion started by: forjohnny
2 Replies
Login or Register to Ask a Question