Solved

Concat strings in unix using multiple variables

Posted on 2009-07-10
2
975 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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…

717 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