Skip to main content
deleted 92 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 239

I have been stuck with this for the past two hours. Basically I have a range of .html files all containing spaces in between.

What I need is to locate the file using find in conjunction with grep, and if a match is found, basically I just want xargs to open it in view mode using less. Nothing fancy.

This is what I tried

pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -trE less echo ./Register for rehousing.html ./Register for rehousing.html pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -0 less ./Register for rehousing.html : No such file or directory 

I have gone through the xargs man but I just can't figure out why xargs doesn't pickup the filename + PATH to file and execute the less command.

The file does exist and here is how it looks

pietro@scum:~/Downloads$ ls -l |grep 'Register\sfor\srehousing.html' -rw-rw-r-- 1 pietro pietro 764611 Mar 14 14:44 Register for rehousing.html 

Much appreciated in advance.

I have been stuck with this for the past two hours. Basically I have a range of .html files all containing spaces in between.

What I need is to locate the file using find in conjunction with grep, and if a match is found, basically I just want xargs to open it in view mode using less. Nothing fancy.

This is what I tried

pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -trE less echo ./Register for rehousing.html ./Register for rehousing.html pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -0 less ./Register for rehousing.html : No such file or directory 

I have gone through the xargs man but I just can't figure out why xargs doesn't pickup the filename + PATH to file and execute the less command.

The file does exist and here is how it looks

pietro@scum:~/Downloads$ ls -l |grep 'Register\sfor\srehousing.html' -rw-rw-r-- 1 pietro pietro 764611 Mar 14 14:44 Register for rehousing.html 

Much appreciated in advance.

I have a range of .html files all containing spaces in between.

What I need is to locate the file using find in conjunction with grep, and if a match is found, basically I just want xargs to open it in view mode using less. Nothing fancy.

This is what I tried

pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -trE less echo ./Register for rehousing.html ./Register for rehousing.html pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -0 less ./Register for rehousing.html : No such file or directory 

I have gone through the xargs man but I just can't figure out why xargs doesn't pickup the filename + PATH to file and execute the less command.

The file does exist and here is how it looks

pietro@scum:~/Downloads$ ls -l |grep 'Register\sfor\srehousing.html' -rw-rw-r-- 1 pietro pietro 764611 Mar 14 14:44 Register for rehousing.html 
Source Link
mailman
  • 143
  • 6

xargs issue with grepped files containing spaces

I have been stuck with this for the past two hours. Basically I have a range of .html files all containing spaces in between.

What I need is to locate the file using find in conjunction with grep, and if a match is found, basically I just want xargs to open it in view mode using less. Nothing fancy.

This is what I tried

pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -trE less echo ./Register for rehousing.html ./Register for rehousing.html pietro@scum:~/Downloads$ find |grep 'Register\sfor\srehousing.html' |xargs -0 less ./Register for rehousing.html : No such file or directory 

I have gone through the xargs man but I just can't figure out why xargs doesn't pickup the filename + PATH to file and execute the less command.

The file does exist and here is how it looks

pietro@scum:~/Downloads$ ls -l |grep 'Register\sfor\srehousing.html' -rw-rw-r-- 1 pietro pietro 764611 Mar 14 14:44 Register for rehousing.html 

Much appreciated in advance.