Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to save a data of a file into a variable? Post 302848771 by pamu on Friday 30th of August 2013 04:17:52 AM
Old 08-30-2013
Code:
while read line
do
id=$(echo $line | cut -d "," -f1)
email=$(echo $line | cut -d "," -f2)

echo $id $email
done<file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read file from within AWK and save $1 to a variable

Hi I am very new to NAWK programming so this question is probably going to sound really stupid: I have a NAWK script which contains a DO loop. During each loop it runs a FORTRAN program which in turn generates two output files , each one containing 2 integer variables. I would appreciate it... (8 Replies)
Discussion started by: robbiegregg
8 Replies

2. Shell Programming and Scripting

Data fetched from text file and save in a csv file

Hi i have wriiten a script which fetches the data from text file, and saves in the output in a text file itself, but i want that the output should save in different columns. I have the output like: For Channel:response_time__24.txt 1547 data points 0.339 0.299 0.448 0.581 7.380 ... (1 Reply)
Discussion started by: rohitkalia
1 Replies

3. Shell Programming and Scripting

select data from oracle table and save the output as csv file

Hi I need to execute a select statement in a solaris environment with oracle database. The select statement returns number of rows of data. I need the data to be inserted into a CSV file with proper format. For that we normally use "You have to select all your columns as one big string,... (2 Replies)
Discussion started by: rdhanek
2 Replies

4. UNIX Desktop Questions & Answers

Why can't I save a VI file after entering data?

Hi I am new to linux, when I typed "vi FILE1" I was able to open VI editor. I added some data and I want to save the file and I tried :w but it threw me an error. "file1" E212: Can't open file for writing Press ENTER or type command to continue why I am not able to save it? I read it... (16 Replies)
Discussion started by: chinnanji
16 Replies

5. Shell Programming and Scripting

perl-data from file save to multidimensional array

i have a file,like 1 3 4 5 6 7 8 9 i want to save it into an array. and then i want to get every element, because i want to use them to calculate. for example: i want to calculate 1 + 3. but i cannot reach my goal. open (FILE, "<", "number"); my @arr; while (<FILE>){ chomp;... (1 Reply)
Discussion started by: pp-zz
1 Replies

6. Shell Programming and Scripting

How to add data from 2 input files and save it in 1 output file

Hi, i have 2 input files which are file1.txt and file2.txt. I need to extract data from file1.txt and file2.txt and save it in file3.txt like example below:- File1.txt ID scrap1 Name scrap1 start 1 end 10 ID scrap2 Name scrap2 start 11 end ... (4 Replies)
Discussion started by: redse171
4 Replies

7. Shell Programming and Scripting

Open Text file input data and save it.

Hi Guys, I have blank file A.txt I will run the script xyz.sh First i want to open a.txt file... Now i will enter some data like XYZ ABC PQR .. Save it and keep continue my script.... END of my script. Thanks (1 Reply)
Discussion started by: asavaliya
1 Replies

8. Shell Programming and Scripting

Read a file name from a text file and save it in a variable

i have a text file consists of different file names like: line 1: lib/libIMb.so message broker file line 2: lil/imbdfg.lil message broker file i need to extract libIMb.so and imbdfg.lil files from those lines and save them in a variable. so that i can search for... (9 Replies)
Discussion started by: santosh2626
9 Replies

9. UNIX for Dummies Questions & Answers

To count total of specific character in a file and save its value to a variable

Hi all, I have a file that contains characters. How do I get total of spesific character from that file and save the count to a variable for doing for calculation. data.txt 1 2 2 2 2 3 3 4 5 6 7 8 5 4 3 4 (5 Replies)
Discussion started by: weslyarfan
5 Replies

10. Shell Programming and Scripting

Read a file and save every word in a variable to use

Hello there so i have a txt file containing word like "one two three four plus four five six". I want to save every word in the file into a variable, and then use that variable to generate real numbers and apply the arithmetic value on them. example: the txt files becomes 123 + 456 and... (10 Replies)
Discussion started by: azaiiez
10 Replies
overlay(3XCURSES)					  X/Open Curses Library Functions					 overlay(3XCURSES)

NAME
overlay, overwrite - copy overlapped windows SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int overlay(const WINDOW *srcwin, WINDOW *dstwin); int overwrite(const WINDOW *srcwin, WINDOW *dstwin); PARAMETERS
srcwin Is a pointer to the source window to be copied. dstwin Is a pointer to the destination window to be overlayed or overwritten. DESCRIPTION
The overwrite() and overlay() functions overlay srcwin on top of destwin. The srcwin and dstwin arguments do not have to be the same size; only text where the two windows overlap is copied. The overwrite() function copies characters as though a sequence of win_wch(3XCURSES) and wadd_wch(3XCURSES) were performed with the desti- nation window's attributes and background attributes cleared. The overlay() function does the same thing, except that, whenever a character to be copied is the background character of the source win- dow, overlay() does not copy the character but merely moves the destination cursor the width of the source background character. If any portion of the overlaying window border is not the first column of a multi-column character, then all the column positions will be replaced with the background character and rendition before the overlay is done. If the default background character is a multi-column character when this occurs, then these functions fail. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. EXAMPLES
Example 1 Implement a pop-up dialog The following example demonstrates the use of overwrite() to implement a pop-up dialog box. #include <curses.h> /* * Pop-up a window on top of curscr. If row and/or col * are -1 then that dimension will be centered within * curscr. Return 0 for success or -1 if malloc() failed. * Pass back the working window and the saved window for the * pop-up. The saved window should not be modified. */ int popup(work, save, nrows, ncols, row, col) WINDOW **work, **save; int nrows, ncols, row, col; { int mr, mc; getmaxyx(curscr, mr, mc); /* Windows are limited to the size of curscr. */ if (mr < nrows) nrows = mr; if (mc < ncols) ncols = mc; /* Center dimensions. */ if (row == -1) row = (mr-nrows)/2; if (col == -1) col = (mc-ncols)/2; /* The window must fit entirely in curscr. */ if (mr < row+nrows) row = 0; if (mc < col+ncols) col = 0; *work = newwin(nrows, ncols, row, col); if (*work == NULL) return (-1); if ((*save = dupwin(*work)) == NULL) { delwin(*work); return (-1); } overwrite(curscr, *save); return(0); } /* * Restore the region covered by a pop-up window. * Delete the working window and the saved window. * This function is the complement to popup(). Return * 0 for success or -1 for an error. */ int popdown(work, save) WINDOW *work, *save; { (void) wnoutrefresh(save); (void) delwin(save); (void) delwin(work); return(0); } /* * Compute the size of a dialog box that would fit around * the string. */ void dialsize(str, nrows, ncols) char *str; int *nrows, *ncols; { int rows, cols, col; for (rows = 1, cols = col = 0; *str != ''; ++str) { if (*str == ' ') { if (cols < col) cols = col; col = 0; ++rows; } else { ++col; } } if (cols < col) cols = col; *nrows = rows; *ncols = cols; } /* * Write a string into a dialog box. */ void dialfill(w, s) WINDOW *w; char *s; { int row; (void) wmove(w, 1, 1); for (row = 1; *s != ''; ++s) { (void) waddch(w, *((unsigned char*) s)); if (*s == ' ') wmove(w, ++row, 1); } box(w, 0, 0); } void dialog(str) char *str; { WINDOW *work, *save; int nrows, ncols, row, col; /* Figure out size of window. */ dialsize(str, &nrows, &ncols); /* Create a centered working window with extra */ /* room for a border. */ (void) popup(&work, &save, nrows+2, ncols+2, -1, -1); /* Write text into the working window. */ dialfill(work, str); /* Pause. Remember that wgetch() will do a wrefresh() */ /* for us. */ (void) wgetch(work); /* Restore curscr and free windows. */ (void) popdown(work, save); /* Redraw curscr to remove window from physical screen. */ (void) doupdate(); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
copywin(3XCURSES), libcurses(3XCURSES), wadd_wch(3XCURSES), win_wch(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 overlay(3XCURSES)
All times are GMT -4. The time now is 10:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy