05-25-2006
adding contents of file
for example i have a file which contains data like:
123
222
325
142
can anyone help me write a script that adds them?
let's say that "total" is the filename...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all,
i'm new to shell scripting, so i'm not sure how to work this. Is it possible to read in the contents of a variable and add it to a command? for example:
------------------------
#!/bin/sh
set example = -dfr
rm ${example}
------------------------
when i run the script, i want... (2 Replies)
Discussion started by: gammarays
2 Replies
2. Shell Programming and Scripting
Dear Experts,
Please help to teach me how to add the filename into the file content so that i can get the output below:-
Actually the file name
***************New output that I want***************
=====2005-11-12=====
EVENTS-20050912 03:33:37 ALARM: BTSSPAN-277-1 30-18013... (2 Replies)
Discussion started by: missutoomuch
2 Replies
3. Shell Programming and Scripting
Hi,
I am not sure how to start doing this so I hope to get some advice as to how to start.
I have 2 files. The source file contains data that I needed is in columns delimited by ";". For example, in this format:
"CONTINENT","COUNTRY","CITY","ID"
"asia","japan","tokyo","123"... (21 Replies)
Discussion started by: ReV
21 Replies
4. UNIX for Dummies Questions & Answers
Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents.....
I try with "diff"...... but confusion how to use "diff" with if ---else
Thanking you (5 Replies)
Discussion started by: krishnampkkm
5 Replies
5. Shell Programming and Scripting
I need some help with adding lines to file and substitute a pattern.
Ok I have a file:
#cat names.txt
name: John Doe
stationed: 1
name: Michael Sweets
stationed: 41
.
.
.
And would like to change it to:
name: John Doe
employed
permanently
stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies
6. Shell Programming and Scripting
Hi,
I want to delete the contents of a file which are matching with contents of other file in shell scripting.
Ex.
file1
sheel,sumit,1,2,3,4,5,6,7,8
sumit,rana,2,3,4,5,6,7,8,9
grade,pass,2,3,4,5,6,232,1,1
name,sur,33,1,4,12,3,5,6,8
sheel,pass,2,3,4,5,6,232,1,1
File2... (3 Replies)
Discussion started by: ranasheel2000
3 Replies
7. Shell Programming and Scripting
Hi,
I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file.
i am able to... (2 Replies)
Discussion started by: seeki
2 Replies
8. Shell Programming and Scripting
Hi one of the output of the command is as below
# sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/'
Resource List : <br>
*************************** 1. row ***************************<br>
... (2 Replies)
Discussion started by: vivek d r
2 Replies
9. Shell Programming and Scripting
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
10. UNIX for Beginners Questions & Answers
I have an array in an external file, "array.txt", which contains:
char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
LEARN ABOUT MOJAVE
curs_scr_dump
curs_scr_dump(3X) curs_scr_dump(3X)
NAME
scr_dump, scr_restore, scr_init, scr_set - read (write) a curses screen from (to) a file
SYNOPSIS
#include <curses.h>
int scr_dump(const char *filename);
int scr_restore(const char *filename);
int scr_init(const char *filename);
int scr_set(const char *filename);
DESCRIPTION
The scr_dump routine dumps the current contents of the virtual screen to the file filename.
The scr_restore routine sets the virtual screen to the contents of filename, which must have been written using scr_dump. The next call to
doupdate restores the screen to the way it looked in the dump file.
The scr_init routine reads in the contents of filename and uses them to initialize the curses data structures about what the terminal cur-
rently has on its screen. If the data is determined to be valid, curses bases its next update of the screen on this information rather
than clearing the screen and starting from scratch. scr_init is used after initscr or a system call to share the screen with another
process which has done a scr_dump after its endwin call. The data is declared invalid if the terminfo capabilities rmcup and nrrmc exist;
also if the terminal has been written to since the preceding scr_dump call.
The scr_set routine is a combination of scr_restore and scr_init. It tells the program that the information in filename is what is cur-
rently on the screen, and also what the program wants on the screen. This can be thought of as a screen inheritance function.
To read (write) a window from (to) a file, use the getwin and putwin routines [see curs_util(3X)].
RETURN VALUE
All routines return the integer ERR upon failure and OK upon success.
X/Open defines no error conditions. In this implementation, each will return an error if the file cannot be opened.
NOTES
Note that scr_init, scr_set, and scr_restore may be macros.
PORTABILITY
The XSI Curses standard, Issue 4, describes these functions (adding the const qualifiers).
The SVr4 docs merely say under scr_init that the dump data is also considered invalid "if the time-stamp of the tty is old" but do not de-
fine "old".
SEE ALSO
curses(3X), curs_initscr(3X), curs_refresh(3X), curs_util(3X), system(3)
curs_scr_dump(3X)