 zBase=$(basename {query})title=${zBase%.*}echo -n $title;The above command copies the filename to the clipboard (using Alfred: the {query} part is from Alfred). Now, I want to copy only the first word of the filename. How can I modify it?Here is an example filename: John 2015 Noun and verb structure.pdfThe above commend gives me [John 2015 Noun and verb structure] in my clipboard. Now, I want to get only John in my clipboard. 
Copy the first word of the filename
bash;shell;filenames
Instead of using external tools like sed, cut or awk, you can simply use the shell's build-in variable expansion that you already used for removing the extension:echo -n ${title%% *}Using double %% means remove the longest match, so you remove everything from the variable starting with the first whitespace.