mv Filename variable to another filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mv Filename variable to another filename
# 1  
Old 04-11-2008
mv Filename variable to another filename

Anyone who can assist :

I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

It will not pass to variable.
Anyone have any ideas what I am doing wrong here.
Thanks



# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`
savegrp=/export/legato/scripts/savegrp_rpt.tmp
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat
cat $* > $savegrp
group=`head -1 $savegrp |grep -v -i media |awk '{print $4,$5}'`>/dev/null
#/usr/ucb/mail -s "$group Test Savegroup Report - $rdat" < $savegrp
#cp $savegrp $rtp_savegrp
# 2  
Old 04-11-2008
Quote:
Originally Posted by gzs553
Anyone who can assist :

I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

It will not pass to variable.

What do you mean, "will not pass to variable"? What does happen? What do you want to happen?

Are both "$group_savegrp_rpt" and "$dat defined"?

Or do you mean:

Code:
rpt_tsavegrp=/export/legato/scripts/${group}_savegrp_rpt.$dat

Quote:
# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`

Why make two identical calls to an external command?

Code:
rdat=$dat

Quote:
savegrp=/export/legato/scripts/savegrp_rpt.tmp
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

Where is $group_savegrp_rpt defined?
Quote:
cat $* > $savegrp

That will fail if there are any spaces in the arguments. Use:

Code:
cat "$@" > "$savegrp"

Quote:
group=`head -1 $savegrp |grep -v -i media |awk '{print $4,$5}'`>/dev/null

What are you sending to /dev/null? If it's outside the backticks, you are doing nothing, since an assignment doesn't produce any output. If it's inside, there will be nothing assign to the variable.

It's not clear what you are trying to do here. Whatever it is, you can almost certainly do it without calling three external commands; in fact, probably without any:

Code:
read a b c d e f < "$savegrp"
case "$a $b $c $d $e $f" in ## adjust to where 'media' might appear
  *media*) group="$d $e" ;;
esac

Quote:
#/usr/ucb/mail -s "$group Test Savegroup Report - $rdat" < $savegrp
#cp $savegrp $rtp_savegrp
# 3  
Old 04-14-2008
For some reason, my $group vairable will not pass to the $savgrp_rpt.
Still doesn't work.

# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`
tmp_savegrp=/export/legato/rpts/savegrp.tmp
cat $@ > $tmp_savegrp
group=`head -1 $tmp_savegrp |grep -v -i media |awk '{print $4,$5,$10}'
/usr/ucb/mail -s "$group Savegroup Report - $rdat" xxxx@xxx.com < $tmp_savegrp
savgrp_rpt=/export/legato/rpts/${group}_savegrp_rpt.$dat
cp $tmp_savegrp $savgrp_rpt
~
# 4  
Old 04-14-2008
Quote:
Originally Posted by gzs553
For some reason, my $group vairable will not pass to the $savgrp_rpt.

Where did you define $group?

If it is in a parent process, did you export it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

2. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

3. Shell Programming and Scripting

Change the filename variable value

Hi guys, I have a variable where i am storing the filename (with full path). I just need the value before ".txt". But instead of getting the filename i am getting the contents of the filename. FileName=/appl/data/Input/US/Test.txt a=`awk -F"." '{print $1}' ${FileName}` echo $a... (3 Replies)
Discussion started by: mac4rfree
3 Replies

4. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

5. Shell Programming and Scripting

Inserting variable value into filename

Greetings, people of UNIX/Linux forums. I am having a problem with a script, where I am trying to create a new variable. The value of this variable would be dependent on the value in a couple other previous variables (all variables are 2-digit integers). Here is my code: #set the stations... (3 Replies)
Discussion started by: TheSMan5
3 Replies

6. Shell Programming and Scripting

variable used as filename

Hello, i'm fairly new to scripting, so please bear with me (I did try looking this up first, i figured it had to have been asked already). #!/bin/bash fileName=`date | sed -n 's/ /_/g p' | sed -n 's/^/Backup_/p' | sed -n 's/$/\.tar/p'`; #THIS SETS BACKUP_DATE echo $fileName #TEST OF VALUE ... (4 Replies)
Discussion started by: jzacsh
4 Replies

7. UNIX for Dummies Questions & Answers

'Crop' date from filename into a variable

Hi all, I have a scenario as below. I created a file - $touch myfile.onlytesting.20090227.txt I want to assign the date only - 20090227 into a variable x. How do I do this in unix command? Please help. Thanks;) (4 Replies)
Discussion started by: luna_soleil
4 Replies

8. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

9. Shell Programming and Scripting

Variable value not being fetched in the filename..

Hi, In the code below, the $DD1, $DD2, $MM1, $MM2 are not fetching the values. Can anybody tell me where have i made wrong. Shift_date.sh is a script which gives the previous date if we give the current date in the format YYYYMMDD and +/- how many days past/future.. Like Shift_date.sh... (3 Replies)
Discussion started by: RRVARMA
3 Replies

10. UNIX for Dummies Questions & Answers

AWK Filename as variable

Need some help. I need to load data into some Oracle tables and one of the pieces of data that I need to load is the filename. This filename is distinct every single time. Basically the last 6 characters will be different with no pattern. ex. testfile_041504_003567 To load the filename... (4 Replies)
Discussion started by: firkus
4 Replies
Login or Register to Ask a Question