Adding values concatenating values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding values concatenating values
# 1  
Old 03-17-2010
Adding values concatenating values

I have the following script in a shell
# The start of a filename

Code:
 
file=$(ls -tr $EMT*.dat | tail -1) # Select the latest file echo $file
file_seq=$( < /u02/sct/banner/bandev2/xxxxxx/misc/EFTSQL.dat)
echo $file_seq
file2 = '$file_seq + 1' 
echo $file2

It is reading a file EFTSQL.dat (just one record 1234)

Here are the results:

Code:
 
+ ls -tr 3526_337092.dat EFT1234.dat HISTOGRAM200910.dat Histogram_200910.dat eluppdtop.dat idoc.dat lockbox_payments.dat
EFT1234.dat # Select the latest file echo 
file_seq=+ + 0< /u02/sct/banner/bandev2/middlebury/misc/EFTSQL.dat
0< /u02/sct/banner/bandev2/middlebury/misc/EFTSQL.dat
1234
echo 
file2 = ' + 1' 
echo

now I want to add 1 and stored in file2, so I ended with 1235
then I need to concatenated. EMTFile2.DAT
SO I ended with EMT12345.dat and stored in a variable so I can rename
a file that I just ftp with that name..
this part seems to be working

Code:
file_seq=$( < /u02/sct/banner/bandev2/xxxxxx/misc/EFTSQL.dat)
echo $file_seq

but this part is not

Code:
file2 = '$file_seq + 1'

and how I concatenate the values EMT||FILE2||.DAT
SO I ended with EMT12345.dat

Last edited by pludi; 03-17-2010 at 09:57 AM..
# 2  
Old 03-17-2010
Code:
# file_seq=4
# file2=$(($file_seq+1))
# echo $file2
5

# 3  
Old 03-17-2010
Ineed to end with 1235 no 5
1234 + 1 = 1235
# 4  
Old 03-22-2010
Code:
#  file_seq=1234
# file2=$(($file_seq+1))
# echo $file2
1235

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding of two column values

Hi cat /tmp/xx.txt 1 4 1 5 1 6 2 1 2 1 2 1 i want to add the values of 2nd column resepect to 1st column values..for 1 in 1st column i need sum of all the values in 2nd column ..pls tell me hw to do it?? (8 Replies)
Discussion started by: Aditya.Gurgaon
8 Replies

2. Shell Programming and Scripting

Adding column values in a file

Hi, I am having a file in the following format. for aaaa 1111 1234 2222 3434 for bbbb 1111 3434.343 2222 2343 for cccc 3333 2343.343 4444 89000 for dddd 1111 5678.343 2222 890.3 aaaa 2343.343 bbbb 34343.343 (5 Replies)
Discussion started by: jpkumar10
5 Replies

3. UNIX for Dummies Questions & Answers

Adding column with values

Dear all, I need your help for my question please I have without header (space separated) and need to add two colomns at the beginning with values my file look like : rs1 a t 0.6 rs2 a c 0.3 rs3 t g 0.8 I need to a new file like: 1 100 rs1 a t 0.6 1 100 rs2 a c 0.3 1 100 rs3 t g... (3 Replies)
Discussion started by: biopsy
3 Replies

4. Shell Programming and Scripting

bash -- concatenating values from variables

Hi This is a simple one but I got a lost in translation when doing. What I want to do, given both variables in the example below, to get one value at the time from both variables, for example: 1:a 2:b etc... I need to get this in bash scripting code: varas="1 2 3 4" varbs="a b c d"... (4 Replies)
Discussion started by: ranmanh
4 Replies

5. Shell Programming and Scripting

Concatenating column values with unique id into single row

Hi, I have a table in Db2 with data say id_1 phase1 id_1 phase2 id_1 phase3 id_2 phase1 id_2 phase2 I need to concatenate the values like id_1 phase1,phase2,phase3 id_2 phase1,phase2 I tried recursive query but in vain as the length of string to be concatenated in quite long. ... (17 Replies)
Discussion started by: jsaravana
17 Replies

6. Shell Programming and Scripting

Adding the values of two file

I have two files as Count1 and Count2. The count contains only one values as 10 and count2 contains only one values as 20. Now I want third file Count3 as count1+Count2. That is it should contain sum of two file(10+20=30) (3 Replies)
Discussion started by: Shell_Learner
3 Replies

7. UNIX for Dummies Questions & Answers

Concatenating arrays cell values in shell scripting

Hi All, I want to concatenate the array cell values and form a string.. Is it possible? for ex. I have an array word_array contains d u m b and after concatenating the string shld be 'dumb' thanks (2 Replies)
Discussion started by: mathur
2 Replies

8. Shell Programming and Scripting

adding values with a loop

Hi there, I am checking disk spaced used on a box # df -k | grep dsk | awk {'print $3'} 2055463 20165785 18310202 32274406 I want to somehow add them up but am no quite sure how to do this in a loop. ...i.e for n in 'df -k | grep dsk | awk {'print $3}' do <some adding... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

9. Shell Programming and Scripting

Concatenating values in a File

Hi All, I have a ',' delimited file and i would like concatenate a new value at a specific column. Example :- xXXX,XYZ,20071005,ABC,DEF,123 xXXX,XYZ,20071005,ABC,DEF,123 xXXX,XYZ,20071005,ABC,DEF,123 The output that i want is xXXX,XYZ,20071005001,ABC,DEF,123... (7 Replies)
Discussion started by: amitkhiare
7 Replies

10. Shell Programming and Scripting

Adding values then consolidating lines

I'm a begginer with scripting... Have a script that pulls check information data. There are multiple lines for each check. ALL the info is the same on the line EXCEPT the charges. ie: same check number, same payee, same patient, same check date, DIFFERENT CHARGE. I need to total the charges... (0 Replies)
Discussion started by: tdavenpo
0 Replies
Login or Register to Ask a Question