Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
added 47 characters in body
Source Link
Moez
  • 33
  • 7

Trying to print full line from a huge file that inclusehas \ (connector for lines)

I am trying to collect lines from a file with the specific word host: for example the word host, I need to directget output of all names of hosts. This is my file:

host= mx,rt,fd,rt,wed,asd, \  fm, jklf,dfd,dfd  host = jd,er,ew,yu,tg,ed,ik,cs,\   fd, gr, jy  host = mz,fg,jh 

I am using : grep

$grep -i host filename | awk '{print $2}' only

only works for the first line , it does not output any name after \

so the output is;

 mx,rt,fd,rt,wed,asd, \ jd,er,ew,yu,tg,ed,ik,cs,\ mz,fg,jh 

as you see I am not getting rest of the line after \

I don't want to get rid of \ I \ I would like to keep it, I can move it and connect all names, so it will be seen as onelineone_line , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

Trying to print full line from a huge file that incluse \

I am trying to collect lines from a file with specific word: for example the word host, I need to direct all names of hosts.

host= mx,rt,fd,rt,wed,asd, \ fm, jklf,dfd,dfd  host = jd,er,ew,yu,tg,ed,ik,cs,\ fd, gr, jy  host = mz,fg,jh 

I am using : grep -i host filename | awk '{print $2}' only works for the first line , it does not any name after \

so the output is;

 mx,rt,fd,rt,wed,asd, \ jd,er,ew,yu,tg,ed,ik,cs,\ mz,fg,jh 

as you see I am not getting rest of the line after \

I don't want to get rid of \ I would like to keep it, I can move it and connect all names so it will be seen as oneline , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

Trying to print full line from a huge file that has \ (connector for lines)

I am trying to collect lines from a file with the specific word host: for example the word host, I need to get output of all names of hosts. This is my file:

host= mx,rt,fd,rt,wed,asd, \  fm, jklf,dfd,dfd host = jd,er,ew,yu,tg,ed,ik,cs,\   fd, gr, jy host = mz,fg,jh 

I am using :

$grep -i host filename | awk '{print $2}'

only works for the first line , it does not output any name after \

so the output is;

 mx,rt,fd,rt,wed,asd, \ jd,er,ew,yu,tg,ed,ik,cs,\ mz,fg,jh 

as you see I am not getting rest of the line after \

I don't want to get rid of \ I would like to keep it, I can move it and connect all names, so it will be seen as one_line , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

added 47 characters in body
Source Link
Moez
  • 33
  • 7

I am trying to collect lines from a file with specific word: for example the word host, I need to direct all names of hosts.

host= mx,rt,fd,rt,wed,asd,
fm, jklf,dfd,dfd host = jd,er,ew,yu,tg,ed,ik,cs,
fd, gr, jy host = mz,fg,jh

host= mx,rt,fd,rt,wed,asd, \ fm, jklf,dfd,dfd host = jd,er,ew,yu,tg,ed,ik,cs,\ fd, gr, jy host = mz,fg,jh 

I am using : grep -i host filename | awk '{print $2}' only works for the first line , it does not any name after \

so the output is; mx,rt,fd,rt,wed,asd, \

jd,er,ew,yu,tg,ed,ik,cs,\

mz,fg,jh

 mx,rt,fd,rt,wed,asd, \ jd,er,ew,yu,tg,ed,ik,cs,\ mz,fg,jh 

as you see I am not getting rest of the line after \

I don't want to get rid of \ I would like to keep it, I can move it and connect all names so it will be seen as oneline , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

I am trying to collect lines from a file with specific word: for example the word host, I need to direct all names of hosts.

host= mx,rt,fd,rt,wed,asd,
fm, jklf,dfd,dfd host = jd,er,ew,yu,tg,ed,ik,cs,
fd, gr, jy host = mz,fg,jh

I am using : grep -i host filename | awk '{print $2}' only works for the first line , it does not any name after \

so the output is; mx,rt,fd,rt,wed,asd, \

jd,er,ew,yu,tg,ed,ik,cs,\

mz,fg,jh

as you see I am not getting rest of the line after \

I don't want to get rid of \ I would like to keep it, I can move it and connect all names so it will be seen as oneline , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

I am trying to collect lines from a file with specific word: for example the word host, I need to direct all names of hosts.

host= mx,rt,fd,rt,wed,asd, \ fm, jklf,dfd,dfd host = jd,er,ew,yu,tg,ed,ik,cs,\ fd, gr, jy host = mz,fg,jh 

I am using : grep -i host filename | awk '{print $2}' only works for the first line , it does not any name after \

so the output is;

 mx,rt,fd,rt,wed,asd, \ jd,er,ew,yu,tg,ed,ik,cs,\ mz,fg,jh 

as you see I am not getting rest of the line after \

I don't want to get rid of \ I would like to keep it, I can move it and connect all names so it will be seen as oneline , but I don't want to do that.

Any idea , it is appreciated, it could be easy , but I can make it work, even when I use tr.

Source Link
Moez
  • 33
  • 7
Loading