question on using fd command

I have been playing with the fd command and i can mostly get it to do what i want but when searching for files that contain a specific string, it finds the files ok but it doesn’t print the file it found the string in
e.g

fd  -e h  -p ~/MyCode/   -x grep trim\(
char * rtrim(char *str);
    char *ltrim(char *str);
    char *rtrim(char *str);
    char *trim(char *str);
    int test_ltrim(void);
    int test_rtrim(void);
    int test_trim(void);
    char *ltrim(char *str);
    char *rtrim(char *str);
    char *trim(char *str);
char * rtrim(char *str);
char * rtrim(char *str);
    int test_ltrim(void);
    int test_rtrim(void);
    int test_trim(void);
    int test_ltrim(void);
    int test_rtrim(void);
    int test_trim(void);
    char *ltrim(char *str);
    char *rtrim(char *str);
    char *trim(char *str);
char * rtrim(char *str);
char * rtrim(char *str);
char * rtrim(char *str);

How do i get fd to print the file names of the results?
TIA

You could probably use fd to print the filenames (e.g. echo {}), but grep can do that as well:

$ man grep | egrep -A 1 ' (-l|-H)'
       -l, --files-with-matches
              Suppress normal output; instead print the name of each input file from which output would normally have been printed.  The scanning will stop on the first match.
       -H, --with-filename
              Print the file name for each match.  This is the default when there is more than one file to search.

AFAICS, you have to call “fd -e h -p ~/MyCode/” to print the found file names before you call “fd -e h -p ~/MyCode/ -x grep trim( . . . )” …

  • “fd” is «simple» – not as «complex» as “find” …