Resolved Piping help

Discussion in 'Mac Programming' started by albacor, Aug 16, 2014.

  1. albacor, Aug 16, 2014
    Last edited: Aug 17, 2014

    albacor macrumors newbie

    albacor

    Joined:
    Mar 18, 2014
    #1
    In Terminal, I'm trying to replace SUBJECT and BODY from the command below:

    Code:
    printf "From: Sender Name <sender@domain.com>\nTo: recipient@domain.com\nSubject: [COLOR="SeaGreen"][B]SUBJECT[/B][/COLOR]\n\n[COLOR="Red"][B]BODY[/B][/COLOR]\n" | /usr/sbin/sendmail -F "Sender Name" -f "sender@domain.com" "recipient@domain.com"
    
    with the piping of
    Code:
    ls *
    I just can't figure out how to do it, any kind soul to help me with this please?
     
  2. dmi, Aug 16, 2014
    Last edited: Aug 17, 2014

    dmi macrumors regular

    Joined:
    Dec 21, 2010
    #2
    Code:
    printf "From: Sender Name <sender@domain.com>\nTo: recipient@domain.com\nSubject: $(ls *)" | /usr/sbin/sendmail -F "Sender Name" -f "sender@domain.com" "recipient@domain.com"
    
    Note that file names containing % in the `ls` may be interpreted as format specification by the printf
     
  3. albacor thread starter macrumors newbie

    albacor

    Joined:
    Mar 18, 2014
    #3
    Damn, why was it so simple? I feel like a fool :mad:

    Thanks a lot pal :)
     

Share This Page