I am trying to use xsel clipboard to pipe search term to grep to search in folder full of txt files. Can anybody suggest a method to do it.
Piping search term from clipboard (not filename) to grep to search a folder
grep;clipboard;xsel
With grep implementations that support of -r option for recursive grep:grep -rFe $(xsel -b -o) /path/to/your/folderFor other grep implementations, use find to look up the files:find /path/to/your/folder -type f -exec \  grep -Fe $(xsel -b -o) /dev/null {} +The /dev/null is to make sure at least 2 file names are passed to grep so grep always prints the name of the files the strings are found in.Note that if the CLIPBOARD selection contains more than one line, each line will be searched separately. For instance, if the selection contains a<newline>b, it will report lines that contain a or b (or both).To match on a<newline>b instead, you could use pcregrep with its multiline mode:pcregrep -rM \Q$(xsel -b -o | sed 's/\\E/&\\&\\Q/g'; printf '\\E') /path/to/folder