last day (15 days later) » 

7:39 PM
1
A: Find lines with exact string bash

anubhavaUsing awk: awk '$1 == "/home/admin"' file /home/admin fileA EDIT: As per comment below you can use: awk -v p=$(pwd) '$1 == p' file Using grep: grep -F '/home/admin ' file /home/admin fileA

 
that grep dont work for me it ll write even the next line because it substring in it
 
There is a space after admin in my suggested grep command to make sure '/home/admin/bin isn't matched. In anycase awk solution is better here.
 
but i have a problem that in my script i use pwd command wich does not work in that quotes
 
You mean /home/admin is actually output of pwd command?
 
yes /home/admin is actually output of pwd command
 
7:39 PM
See updated answer, you can use: awk -v p=$(pwd) '$1 == p' file
 
that works but just particulary, i will show u exact input if u could help...
/home/majkl/bin subor
/home/majkl/ subor1
/home/majkl/bin subor
 
yes sure
 
and my script work in /home/majkl/bin directory, but it not work for /home/majkl/
 
I think it is due to trailing / after majkl
 
oh that was mistake, the / isnt there
 
7:46 PM
when you type pwd what do you get? /home/majkl right?
 
but in file you have /home/majkl/ subor1 not /home/majkl subor1
 
oh right
thats it :D
Thank you very much :D
 
you're welcome :)
 

last day (15 days later) »