Sponsored Content
Top Forums Shell Programming and Scripting Extract a string from a file and store it in variable Post 302760427 by Parameswaran on Thursday 24th of January 2013 03:41:34 AM
Old 01-24-2013
Extract a string from a file and store it in variable

Hi,

I've a file ImageSizeDetails.txt with the following contents:

Code:
Image Name:   swncd 01.10.00.04
Created:      Wed Jan  9 14:05:48 2013
Image Type:   ARM Linux Multi-File Image (gzip compressed)
Data Size:    7351011 Bytes = 7178.72 kB = 7.01 MB
Load Address: 00008000
Entry Point:  00008000
Contents:
   Image 0: 1672879 Bytes = 1633.67 kB = 1.60 MB
   Image 1: 5678119 Bytes = 5545.04 kB = 5.42 MB

I need to extract the size of Image 0 in bytes (i.e) 1672879 alone& save it in a variable. Kindly help me with a shell script

Last edited by Scrutinizer; 01-24-2013 at 04:54 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract from string variable into new variables

I have a variable which consists of a string like this: 001 aaabc 44 a bbb12 How do I extract each substring, delimited by the spaces, into new variables - one for each substring? eg var1 will be 001, var2 will be aaabc, var3 will be 44, var4 will be a, etc? I've come up with this:... (2 Replies)
Discussion started by: Sniper Pixie
2 Replies

2. Shell Programming and Scripting

Extract numbers from a string and store in variables

Hi All, Is it possible in Unix shell script to extract numbers from a string containing ".", such as; 5.2.314 And store in variables so; var1 = 5 var2 = 2 var3 = 314 Thanks in advance for any help anyone can provide dave (6 Replies)
Discussion started by: davewg
6 Replies

3. UNIX for Dummies Questions & Answers

Using GREP/AWK to extract a number and store it as a variable

Hello, I have a question regarding the awk command. Here is the line I need to grep: 1 F= -.13250138E+03 E0= -.13249556E+03 d E =-.174650E-01 mag= 35.2157 Instead of displaying the number in red I would like to store it as a variable such as X. Is there a way to do this? Thanks for any... (3 Replies)
Discussion started by: modey3
3 Replies

4. Shell Programming and Scripting

Search for string in a file and extract another string to a variable

Hi, guys. I have one question: I need to search for a string in a file, and then extract another string from the file and assign it to a variable. For example: the contents of the file (group) is below: ... ftp:x:23: mail:x:34 ... testing:x:2001 sales:x:2002 development:x:2003 ...... (6 Replies)
Discussion started by: daikeyang
6 Replies

5. Shell Programming and Scripting

sub-string extract between variable delimiters

I need to extract certain pieces from a string, wher delimiters may vary. For example A0 B0 C0 12345677 X0 Y0 Z0 A1-B1 C1 12345678 X1 Y0 Z0 A1/B2 C77 12345679 X2 Y0 Z0 I need to get C0 12345677 X0 C1 12345678 X1 C77 12345679 X2 I tried sed, see example below: echo 'A0 B0... (2 Replies)
Discussion started by: migurus
2 Replies

6. Shell Programming and Scripting

Search file for string and store last result to variable

Hi, I'm trying to search a text file for a string: "energy(sigma->0)=". To do so, I executed the grep command, which returned many matches, for example: energy without entropy = -112.16486170 energy(sigma->0) = -112.16520778 energy without entropy = -112.16488936 ... (5 Replies)
Discussion started by: gwr
5 Replies

7. Programming

how to store string in variable

sorry i'm newbies c programer how to store string to variable with value flexible. example int hh=1; ---> value flexible 1,2,3,4,5; int xx=1; ---> value flexible 1,2,3,4,5; char test="value=%d and value=%d",hh,xx; --> not working char test2="value2=%d and value2=%d",hh,xx; --> not... (1 Reply)
Discussion started by: slackman
1 Replies

8. Shell Programming and Scripting

Search for string in a file, extract two another strings and concatenate to a variable

I have a file with <suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux"> Need to find word "build" then extract build number, which is 19921 also release number, which is 6.1.5 then concatenate them to one variable as... (6 Replies)
Discussion started by: garg
6 Replies

9. UNIX for Dummies Questions & Answers

Extract variable name in a string

Hi, I'm doing a script to list all scripts called by a "master" script. But I have an issue as there is some variables in the name of the called scripts. Example: % cat master_script.sh ENVIR=PROD VERSION=1.2 /users/maturix/$ENVIR/program_$VERSION.shI would like my script displays a kind... (7 Replies)
Discussion started by: maturix
7 Replies

10. UNIX for Dummies Questions & Answers

Extract data from a file and store it in a variable

Hi , I have an file like below , cat input.txt 'Pattern2' => 'blahdalskdahdlahldahdlakhdlahdlkajdlkaadasdadadadadadadasda ajlalnalndklandlaksdlkaddd' 'Pattern2' => 'aohaonalkndlanldandlandklasnldnaldnak' ............ ........ ..... Here is what am trying to do , I want to grep for... (3 Replies)
Discussion started by: scott_cog
3 Replies
Image::EXIF(3pm)                                        User Contributed Perl Documentation                                       Image::EXIF(3pm)

NAME
Image::EXIF - Perl extension for exif library SYNOPSIS
use Image::EXIF; use Data::Dumper; my $exif = Image::EXIF->new($file_name); # or: my $exif = Image::EXIF->new; $exif->file_name($file_name); my $image_info = $exif->get_image_info(); # hash reference my $camera_info = $exif->get_camera_info(); # hash reference my $other_info = $exif->get_other_info(); # hash reference my $point_shoot_info = $exif->get_point_shoot_info(); # hash reference my $unknown_info = $exif->get_unknown_info(); # hash reference my $all_info = $exif->get_all_info(); # hash reference print Dumper($all_info); DESCRIPTION
Perl package Image::EXIF based on exiftags by Eric M. Johnston: <http://johnst.org/sw/exiftags/>. AUTHORS
o Aaron Crane <arc@cpan.org> (current maintainer) o sergey s prozhogin <ccpro@rrelaxo.org.ru> REPORTING BUGS
Please report bugs at either of the following locations: o https://rt.cpan.org/Public/Dist/Display.html?Name=Image-EXIF <https://rt.cpan.org/Public/Dist/Display.html?Name=Image-EXIF> o https://github.com/arc/p5-image-exif <https://github.com/arc/p5-image-exif> SEE ALSO
exiftags. perl v5.14.2 2012-05-11 Image::EXIF(3pm)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy