Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:38:42+00:00 2026-06-09T14:38:42+00:00

Use case: I want to pass an email message from procmail to a shell

  • 0

Use case: I want to pass an email message from procmail to a shell script and have the script store the Subject: header value as one variable and the Return-Path: header value.

As a test, I’m using the following script:

#!/bin/bash
while read data; do
        SearchCriteria1=$(echo "$data" | grep "Subject: " | cut -c 9-)
        SearchCriteria2=$(echo "$data" | grep "Return-Path: " | cut -c 13-)
        echo "$SearchCriteria1" > test.1
        echo "$SearchCriteria2" > test.2
done

The echo statements are just a test. I plan to use the variables later in the script.

When I try this though, test.1 and test.2 just have blank lines. I know I’m missing something obvious. Can someone please point me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:38:43+00:00Added an answer on June 9, 2026 at 2:38 pm

    For every line, you grep the line, leaving you either with the line or no line. Then you overwrite a file with that line (which will likely be empty most iterations). So if both those files are empty, the last line of input contains neither Subject: or Return-Path:.

    This is probably how I’d do it:

    #!/usr/bin/env bash
    while read -r key value; do
        case $key in 
            Subject:) subject=$value;;
            Return-Path:) return_path=$value;;
        esac
    done
    echo "<$subject> <$return_path>"
    

    I say probably because I don’t know what the input will look like.

    See also http://mywiki.wooledge.org/BashFAQ/001

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The use case I want to achive is. 1. Fetch XML from a remote
I want to use Case When with AND condition and it is not calculating
I want to use CASE in my stored procedure. I am getting some syntax
Use case: I've just entered insert mode, and typed some text. Now I want
I want to use a case statement where my logic determines a date. If
I want to use the pl/sql case when statement like in java or c++.
I have a control with a dependency property which I want to pass which
I have the following use case: I need to process a big number of
I have a common use case that I'd like to write a function for:
My use case is simple. I have a root domain object which references a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.