Grep command showing wrong output in Linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep command showing wrong output in Linux
# 1  
Old 01-16-2012
Grep command showing wrong output in Linux

Hi All
I am trying to run a script in linux wherein i have a command like this
Code:
grep ^prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp
djpHewr2XFMAttunitySetup_ae1_tmp is a temporary file in which the user value is stored but this command in the script returns me balnk value whereas it has a value.

Not understanding why is this command in the scipt returning a blank value. Can anyone please help me on this.

Thanks
# 2  
Old 01-16-2012
Are you sure that you have a line that starts with prmAttunityUser in the file djpHewr2XFMAttunitySetup_ae1_tmp

because testing here, that format works perfectly
# 3  
Old 01-16-2012
The value does exists in the file.$prmAttunityUser=ais
# 4  
Old 01-16-2012
$prmAttunityUser=ais =/= prmAttunityUser=ais did you mean to grep for
grep ^\\\$prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp
# 5  
Old 01-16-2012
The entire logic is this
Code:
for y in $params; do
       for pf in $parfile; do
          ret=`grep \^$y\= $pf`
          if [ "$ret" != "" ]; then
             prm=$ret
          fi
       done
       if [ "$prm" == "" ]; then
          echo "parameter not found ($y) for job ($x.$invocation_id)"
          echo "Returning value 1"
          return 1
          exit
       else
          prmString[$cnt]="${prmString[$cnt]}  -param $prm"
       fi
    done

HEre parfile contains a value like prmAttunityuser = ais but still it returns blank.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command showing no output!

Hi Folks, I have a situation here, where no command is giving any output, and it's not even showing any error message also. What could be the reason? (3 Replies)
Discussion started by: nixhead
3 Replies

2. Shell Programming and Scripting

Time field showing Zero in ps command output

F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME COMD 401 S catmgr 5748 5742 0 154 20 e0000006d48cd080 133 e0000003fb6e7200 11:22:32 ? 0:00 /opt/ssh/libexec/sftp-server 3401 R catmgr 5742 5631 0 152 20 e0000005f974fa00 750 ... (4 Replies)
Discussion started by: TomG
4 Replies

3. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

4. Solaris

Network interface showing wrong configuratoin

on both of my T2000 I am seeing same values of 100Mbps for e1000g0 ethernet port. i know all four ethernet ports on T2000 are gigabit ports so why is my first link showing as 100Mbps and how can i correct it? # dladm show-dev e1000g0 link: up speed: 100 Mbps ... (1 Reply)
Discussion started by: aliyesami
1 Replies

5. Shell Programming and Scripting

grep only a string on command output

How can I grep exactly a string that has .,/ characters using grep? Example: I want to grep ONLY string1 and not string1.more or string1.more.evenmore #lsauth ALL|grep 'string1' All output: string1 <--- This is the only I want. string1.more string1.evenmore. more.string1... (4 Replies)
Discussion started by: iga3725
4 Replies

6. Shell Programming and Scripting

Wrong output in find command

Hi guys - I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good. I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR. MYSIZE=$(find /home/student/dir1... (8 Replies)
Discussion started by: DallasT
8 Replies

7. Emergency UNIX and Linux Support

getting wrong output with AWK command!!!

i have a file which gets appended with 9 records daily and the file keeps growing from then...i use to store the previous day files count in a variable called oldfilecount and current files count as newfilecount.my requirement is that i need to start processing only the new records from the... (3 Replies)
Discussion started by: ganesh_248
3 Replies

8. Shell Programming and Scripting

tr command giving wrong output

Hi All, i have a file which have many fields delimited by ,(comma) now i have to show only few fields and not all. the sample text file looks like this: TYPE=SERVICEEVENT, TIMESTAMP=05/06/2009 11:01:40 PM, HOST=sppwa634, APPLICATION=ASComp, FUNCTION=LimitsService, SOU... (8 Replies)
Discussion started by: usha rao
8 Replies

9. Shell Programming and Scripting

Sort command giving wrong output

Hi all, I have a problem with sort command. i have a file which looks like this: "file1 1073 java/4 1073 java/180 1073 java/170 1073 java/176 1073 java/167 1073 java/40 1073 java/33 1073 java/136 28988 java/76 28988 java/73 28988 java/48 28988 java/26" and i want to sort... (8 Replies)
Discussion started by: usha rao
8 Replies

10. UNIX for Dummies Questions & Answers

word count showing wrong number of lines

Hi , I am using SUN OS Version 5.6. I have a file that contains records of length 270. when I do 'set nu' in vi editor, I get the count as 86. whereas when I do "wc -l" on the command prompt, it shows the count as only 85. this is very strange. why would the 'wc' show 1 record less. The job... (3 Replies)
Discussion started by: tselvanin
3 Replies
Login or Register to Ask a Question