Sponsored Content
Top Forums Shell Programming and Scripting Storing the contents of a file in a variable Post 302365964 by dr.house on Wednesday 28th of October 2009 12:14:07 PM
Old 10-28-2009
Quote:
Originally Posted by proactiveaditya
Code:
echo $varname

You may want to enclose the variable in double quotes ...

Code:
[house@leonov] data=$( cat in.file ); echo "$data"
+-----------------------------------+-----------+
| Variable_name                     | Value     |
+-----------------------------------+-----------+

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading from a file and storing it in a variable

Hi folks, I'm using bash and would like to do the following. I would like to read some values from the file and store it in the variable and use it. My file is 1.txt and its contents are VERSION=5.6 UPDATE=4 I would like to read "5.6" and "4" and store it in a variable in shell... (6 Replies)
Discussion started by: scriptfriend
6 Replies

2. Shell Programming and Scripting

How to read contents of a file into variable :(

My file is in this format : username : student information : default shell : student ID Eg : joeb:Joe Bennett:/bin/csh:1234 jerryd:Jerry Daniels:/bin/csh:2345 deaverm: Deaver Michelle:/bin/bash:4356 joseyg:Josey Guerra:/bin/bash:8767 michaelh:Michael Hall:/bin/ksh:1547 I have to... (1 Reply)
Discussion started by: dude_me5
1 Replies

3. Homework & Coursework Questions

How to read contents of a file into variable :(

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to read the contents of each field of a file creating user accounts. The file will be of format : ... (6 Replies)
Discussion started by: dude_me5
6 Replies

4. Shell Programming and Scripting

Storing lines of a file in a variable

i want to store the output of 'tail -5000 file' to a variable. If i want to access the contents of that variable, it becomes kinda difficult because when the data is stored in the variable, everything is mushed together. you dont know where a line begins or ends. so my question is, how can i... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

storing a value from another file as a variable[solved]

Hi all, im having snags creating a variable which uses commands like cut and grep. In the instance below im simply trying to take a value from another file and assign it to a variable. When i do this it only prints the $a rather than the actual value. I know its simple but does anyone have any... (1 Reply)
Discussion started by: somersetdan
1 Replies

6. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

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

7. Shell Programming and Scripting

Storing multiple file paths in a variable

I am working on a script for Mac OS X that, among many other things, gets a list of all the installed Applications. I am pulling the list from the system_profiler command and formatting it using grep and awk. The problem is that I want to be able to use each result individually later in the script.... (3 Replies)
Discussion started by: cranfordio
3 Replies

8. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

9. UNIX for Beginners Questions & Answers

Storing file contents to a variable

Hi All, I was trying a shell script. I was unable to store file contents to a variable in the script. I have tried the below but unable to do it. Input = `cat /path/op.diary` Input = $(<op.diary) I am using ksh shell. I want to store the 'op.diary' file contents to the variable 'Input'... (12 Replies)
Discussion started by: am24
12 Replies

10. Shell Programming and Scripting

awk to compare each file in two directores by storing in variable

In the below bash I am trying to read each file from a specific directory into a variable REF or VAL. Then use those variables in an awk to compare each matching file from REF and VAL. The filenames in the REF are different then in the VAL, but have a common id up until the _ I know the awk portion... (15 Replies)
Discussion started by: cmccabe
15 Replies
DtEditorFormat(library call)											      DtEditorFormat(library call)

NAME
DtEditorFormat -- format all or part of the contents of a DtEditor widget SYNOPSIS
#include <Dt/Editor.h> DtEditorErrorCode DtEditorFormat( Widget widget, DtEditorFormatSettings *formatSettings, unsigned int amountToFormat); DESCRIPTION
The DtEditorFormat function formats all or part of the contents of the DtEditor widget according to the current text format settings in the Format Settings dialog. These options specify which margins and alignments (left aligned, right aligned, justified or centered) are used. Optionally, alternative settings can be passed as an argument to DtEditorFormat in a data structure. This function formats either the paragraph containing the insertion cursor or the entire contents of the DtEditor widget, depending on the value of the amountToFormat argu- ment. The Format Settings dialog is displayed with DtEditorInvokeFormatDialog(3). For a complete description of formatting and the Format Set- tings dialog, see DtEditor. The widget argument specifies the editor widget ID. The formatSettings argument specifies left margin value, right margin value and the justification style. The LeftMargin and RightMargin fields of DtEditorFormatSettings must be zero or larger. The Alignment field can have a value of DtEDITOR_ALIGN_CENTER, DtEDI- TOR_ALIGN_JUSTIFY, DtEDITOR_ALIGN_LEFT or DtEDITOR_ALIGN_RIGHT. If the formatSettings argument is NULL, DtEditorFormat uses the last format settings specified in the Format Settings dialog. When the amountToFormat argument is set to DtEDITOR_FORMAT_ALL, it reformats all the text in the edit window. When this argument is set to DtEDITOR_PARAGRAPH, only the paragraph containing the insertion cursor is formatted. For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). For a complete definition of DtEditorFormatSettings, see Dt/Editor.h - DtEditor(5). RETURN VALUE
Upon successful completion, the DtEditorFormat function returns DtEDITOR_NO_ERRORS; otherwise, it returns one of the following values: DtEDITOR_NO_TMP_FILE The DtEditorFormat function cannot create two temporary files in the directory returned by tmpnam3S. DtEDITOR_ILLEGAL_SIZE The left or right margin values are negative. DtEDITOR_INVALID_RANGE The amountToFormat argument is not recognized. DtEDITOR_INVALID_TYPE The Alignment field is not recognized. SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), DtEditorInvokeFormatDialog(3); tmpnam3S. DtEditorFormat(library call)
All times are GMT -4. The time now is 11:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy