Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Storing file contents to a variable Post 302970993 by am24 on Friday 15th of April 2016 03:06:23 AM
Old 04-15-2016
Hi Ravindhar,

Thanks for suggestions. I will try it out and let you know the results.

---------- Post updated 04-15-16 at 02:06 AM ---------- Previous update was 04-14-16 at 10:04 AM ----------

Hi Ravindhar,

I have tried the code as you suggested and the below is working.

Input1="/tmp/chumma_file"

I also tried with while loop. But it did not work.

Code:
while read line
do
      echo $line  ##### just for an example
done < "$Input1"

However i have proceeded with the first Scenario . Thank you so much for your time and suggestions on this :-)

Hi Cero,

Thanks for your suggestion. I have tried the below code which you suggested but it did not work.

Input1=`cat /path/op.diary`

So I have proceeded with the code which Ravindhar suggested.

Hi Rudi,

Thanks for your time on this. Unfortunately i am not clear on my specifications to you. But thanks a lot for looking into this. As mentioned above i have proceeded with the code which Ravindhar suggested and it worked fine.

Once again thank you all :-)

Regards,
am24
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Storing the contents of a file in a variable

There is a file named file.txt whose contents are: +-----------------------------------+-----------+ | Variable_name | Value | +-----------------------------------+-----------+ | Aborted_clients | 0 | | Aborted_connects | 25683... (6 Replies)
Discussion started by: proactiveaditya
6 Replies

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

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
demos::widget_lib::trace2(3)				       perl/Tk Documentation				      demos::widget_lib::trace2(3)

NAME
Tk::TraceText - Text contents defined by a traced variable. SYNOPSIS
$tt = $parent->TraceText(-option => value, ... ); DESCRIPTION
Create a new TraceText widget that is derived from the standard Text widget. Because it inherits all the base options and methods it behaves just like a Text widget. Additionally, TraceText adds a -textvariable option, which is a reference to a Perl scalar that defines the contents of the widget. Based on the Tcl/Tk TracedText "overridden widget" by Kevin Kenny. -textvariable A scalar reference. The value of the variable defines the contents of the TraceText widget. Using the keyboard to insert or delete text changes the value of the variable, and changing the variable alters the contents of the TraceText widget. METHODS
Standard Text widget methods. ADVERTISED SUBWIDGETS
None. EXAMPLE
my $tt = $mw->TraceText( -textvariable => $scalar ); AUTHOR
Stephen.O.Lidie@Lehigh.EDU Copyright (C) 2003 - 2004, Steve Lidie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. KEYWORDS
text, trace Tk804.03 2014-06-10 demos::widget_lib::trace2(3)
All times are GMT -4. The time now is 12:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy