12-31-2008
Hi Johnson,
Your code is working. Can you please suggest me how to change the existing script to dynamic script with parameters, such that it take three file names as 3 parameters and add the content of first two files and insert the sum value into third file? Your help will be appreciated.
script(file1name, file2name, file3name)
{
body of script
file 3 should contain sum of file1 content and file2.
}
Thanks!
Praveen
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file file like this. I want to sum all column 1 values.
input
A 2
A 3
A 4
B 4
B 2
Out put
A 9
B 6 (3 Replies)
Discussion started by: suresh3566
3 Replies
2. Shell Programming and Scripting
Hi.
Im looking for way to sum numbers from top. For example i have such command
top -b -n | grep Cpu | cut -c 35 - 39
which give me output 97.0 . Ho can i do with that value any arithmetic actions (for example 97.0 +1)?
Using
c = $((top -b -n | grep Cpu | cut -c 35 - 39))
gives me... (8 Replies)
Discussion started by: qdf
8 Replies
3. Shell Programming and Scripting
Hi All,
I have a file which is having 3 columns as (string string integer)
a b 1
x y 2
p k 5
y y 4
.....
.....
Question:
I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies
4. Shell Programming and Scripting
I am running the following script :
cat ind_sls_extr_UX.out_sorted | while read each_rec
do
count=`echo "${each_rec}" | cut -c1-2`
if
then
final_amount=0
amount=`echo "${each_rec}" | cut -c280-287`
echo "${amount}"
final_amount=`expr ${amount} + ${amount}`
... (7 Replies)
Discussion started by: mady135
7 Replies
5. Shell Programming and Scripting
I have a file in the following layout:
201008005946873001846130058030701006131840000000000000000000
201008006784994001154259058033001009527844000000000000000000
201008007323067002418095058034801002418095000000000000000000
201008007697126001722141058029101002214158000000000000000000... (2 Replies)
Discussion started by: jclanc8
2 Replies
6. Shell Programming and Scripting
I am new to shell script.I have records like below in 4 different files which have about 10000 records each, all records unique and sorted based on column 2.
1 2 3 4 5 6
---------------------------
SR|1010478|000044590|1|0|0|
SR|1014759|000105790|1|0|0|
SR|1016609|000108901|1|0|0|... (2 Replies)
Discussion started by: reach.sree@gmai
2 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I would like to be able to sum up the counts of a column by the ID of another column. Example (although the actual file I have has thousands of IDs):
Input file:
A1BG-AS1:001 3
A1BG-AS1:002 0
A1BG-AS1:003 2
A1CF:001 1038
A1CF:002 105
A1CF:003 115
A1CF:004 137
Desired output... (3 Replies)
Discussion started by: fadista
3 Replies
8. UNIX for Dummies Questions & Answers
I have a file with data merged from multiple files. File contains header, data and trailer of multiple files. The trailer starts with 99 and delimiter is ~.
Trailer
99~120
99~30
As it is a merged file we i have multiple lines followed by 99~. Need help to find sum of values which are there... (4 Replies)
Discussion started by: santoshdrkr
4 Replies
9. Shell Programming and Scripting
I have a file (let say file B) like this:
File B:
A1 3 5
A1 7 9
A2 2 5
A3 1 3
The first column defines a filename and the other two define a range in that specific file. In the same directory, I have also three more files (File A1, A2 and A3). Here is 10 sample lines... (3 Replies)
Discussion started by: Bastami
3 Replies
10. Shell Programming and Scripting
Hi Gurus,
I have requirement need to sum the value, the logic is if the value is negative then time -1, I tried below two ways. one is failed, another one doesn't work.
awk -F"," '{if($8< 0 $8*-1 else $8) sum+=$8}{print sum, $8} END{printf("%.2f\n",sum)}'
awk -F","... (4 Replies)
Discussion started by: ken6503
4 Replies
script(1) User Commands script(1)
NAME
script - make record of a terminal session
SYNOPSIS
script [-a] [filename]
DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the
record is saved in the file typescript. See WARNINGS.
The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends
when the forked shell exits or when Control-d is typed.
OPTIONS
The following option is supported:
-a Appends the session record to filename, rather than overwriting it.
NOTES
script places everything that appears on the screen in filename, including prompts.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
SEE ALSO
attributes(5)
WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a
privileged user, that is, root. Be sure that typescript is not a link before running script.
SunOS 5.10 30 Jan 2004 script(1)