Solved

Concat strings in unix using multiple variables

Posted on 2009-07-10
2
968 Views
Last Modified: 2013-12-26
In my shell script I am trying to get a subject line (string)

I have already:
today_dt=`date +%m%d%Y`

I need to create a string $mysubjectline = "Files for" + today_dt +"for PROJECT1"

and then do :
#tar -cvf dailyfiles.tar file1.html file2.csv  
#uuencode dailyfiles.tar dailyfiles.tar | mail -s $mysubjectline tom.dick@harry.com

Whats the best way to concat my string with the date variable and use in subjectline
0
Comment
Question by:LuckyLucks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Expert Comment

by:kevin_u
ID: 24824998
today_dt=`date +%m%d%Y`
mysubjectline="Files for $today_dt for PROJECT1"
tar -cvf dailyfiles.tar file1.html file2.csv  
uuencode dailyfiles.tar dailyfiles.tar | mail -s "$mysubjectline" tom.dick@harry.com

variables are expanded inside of double quoted strings, so concatenation is not usually needed.

I also put quotes around $mysubjectline so that the multiple words in the subject are treated as one argument to the -s option of mail.
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 24825253
the script below will do the job

#!/usr/bin/ksh
today_dt=`date +%m%d%Y`
tar -cvf dailyfiles.tar file1.html file2.csv  
uuencode dailyfiles.tar dailyfiles.tar | mail -s "Files for $today_dt for PROJECT1" tom.dick@harry.com

no need for this line since it could be put directly as the subject of mail

mysubjectline="Files for $today_dt for PROJECT1"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question