score:1
Accepted answer
when you quote the variable $2
, that prevents the shell from expanding wildcards. so you need to do:
pdfgrep -h "$1" $2
however, this will have a problem if the folder name contains spaces, because it also does word splitting. it would be better if you allowed the original shell to expand the wildcard, by not quoting the argument to the script:
bash pdfgrep.ssh "string to search" folder_to_scan/*
then you need to change the script so it passes all the arguments to pdfgrep
, not just the first two:
pdfgrep -h "$@"
now i'm not sure what the point of the script is. all it does is insert the -h
option to the beginning, which is less typing that bash pdfgrep.ssh
.
Source: stackoverflow.com
Related Query
- Passing folder as flag in regex
- BASH - find specific folder with find and filter with regex
- passing bash array elements to awk regex inside loop
- Regex find and copy in bash (preserving folder structure)?
- Match folder name from url using regex
- Passing a Bash Array Element to an Awk Regex Expression
- How to unzip a folder passing a variable?
- Change directory to a folder whose name is in regex notation
- Linux bash regex global flag
- Copy files into folders based on regex matchs of file and folder names
- Passing a command line argument or flag to NPM package.json scripts
- Passing Bash shell varialbes in AWK. One regex works the other does not
- Looking for a regex pattern, passing that pattern to a script, and replacing the pattern with the output of the script
- Cannot delete folder path when passing Rmarkdown variable into Bash
- bash and grep: passing of regex parameter
- Regex in Expect script passing only the first match
- passing values to a flag in bash script
- passing folder path as argument from windows batch file to cygwin bash script
- Passing variable in regex (bash)
- Passing parameters to a Bash function
- Find and kill a process in one line using bash and regex
- Capturing Groups From a Grep RegEx
- Check folder size in Bash
- Check if a string matches a regex in Bash script
- Renaming files in a folder to sequential numbers
- Save file to specific folder with curl command
- Delete node_modules folder recursively from a specified path using command line
- How to use Bash to create a folder if it doesn't already exist?
- How can I match a string with a regex in Bash?
- Copy folder recursively, excluding some folders
More Query from same tag
- How can I output and format the latest entry in an org file to the terminal?
- I can't install Realm Object Server
- Edit file in unix using SED
- Bash script to list all devices of PCI Bridge type
- Exit from a sourced script that exports variables
- mv with wildcard fails with "No such file or directory" if no files match wildcard
- Decrypt 3des cfb string in bash
- Making bash script with command already containing '$1'
- what is the correct syntax for awk's printf to insert multiple variables?
- How can I write a simple script on android
- Passing PHP variables to Bash - more than one breaks it
- Use of awk/sed to get specific data in rows based on a pattern and arrange them in columns in unix
- Using a variable's value as password for scp, ssh etc. instead of prompting for user input every time
- Bash script using dmesg to see a message on terminal when a mouse is plugged and unplugged
- Change the numerical sequence in filenames using bash/shell command
- Check wordcount in until loop
- Run the same shell script on multiple files at the same time
- Sed not replacing new line pattern in text file
- Ruby installation results in Terminal opening as cat
- how to process filenames correct with shell script
- What is the Bash equivalent of Python's pass statement
- Accessing existing Windows environment variables from WSL
- Adding nested dict key to plist
- Get the status returned from the process that just finished
- What file explorer can I use in Cygwin with UNIX like paths?
- Make a function locate using mdfind on MacOS Catalina
- zip error - Nothing to do
- Use of if [[ ]] (bash)
- Bash script to install specific package from ubuntu (if exists)
- bash script to execute a command on remote servers is printing the output twice