Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Concat strings in unix using multiple variables

Posted on 2009-07-10
2
Medium Priority
?
989 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Suggested Courses

610 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