Sponsored Content
Top Forums Shell Programming and Scripting bash, extract value from the file to the variable Post 302310024 by patrykxes on Thursday 23rd of April 2009 12:52:24 PM
Old 04-23-2009
bash, extract value from the file to the variable

Hi
I've got phrases (string) in phrases.txt file and I've got script.sh.

How can I draw out the first line from phrases.txt, save it in variable PHRASE and perform the content of script.sh, and then draw out the second line from phrases.txt, save it in the same variable PHRASE and perform the content of script.sh, and so on... ?

At the moment variable PHRASE is contained in script.sh

At the moment when there is one phrase in one line in phrases.txt it works without problems, the trouble starts when there is more than one phrase in phrases.txt

Best Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to extract paragraphs from file in BASH script followed by prefix ! , !! and !!!

I]hi all i am in confusion since last 2 days :( i posted thraed yesterday and some friends did help but still i couldnt get solution to my problem let it be very clear i have a long log file of alkatel switch and i have to seperate the minor major and critical alarms shown by ! , !! and !!!... (6 Replies)
Discussion started by: nabmufti
6 Replies

2. Shell Programming and Scripting

Extract Variable and Append it to the file

I have a file named xyz_extract_file_20091201.dat and I need to strip out 20091201 from the file name and append this value as a first field in all the records in the file. Can you please help? Thanks. Eg. Input File: xyz_extract_file_20091201.dat ------------ Campaign1,A2347,Grp_id1... (1 Reply)
Discussion started by: shekharaj
1 Replies

3. Shell Programming and Scripting

bash extract all occurences delimited from <name> and </name> tags from an xml file

I need to extract all text delimited from <name> and </name> tags from an xml file, but not only first occurence. I need to extract all occurences. I've tried with this command: awk -F"<name>|</name>" 'NF>2{print $2}' but it give only first occurence. How can i modify it? (18 Replies)
Discussion started by: ingalex
18 Replies

4. Shell Programming and Scripting

how to write bash script that will automatically extract zip file

i'm trying to write a bash script that that will automatically extract zip files after the download. i writed this script #!/bin/bash wget -c https://github.com/RonGokhle/kernel-downloader/zipball/master CURRENDIR=/home/kernel-downloader cd $CURRENDIR rm $CURRENDIR/zipfiles 2>/dev/null ... (2 Replies)
Discussion started by: ron gokhle
2 Replies

5. Shell Programming and Scripting

Extract a string from a file and store it in variable

Hi, I've a file ImageSizeDetails.txt with the following contents: 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: ... (6 Replies)
Discussion started by: Parameswaran
6 Replies

6. Shell Programming and Scripting

Extract text from file then write variable

I have a text file that has many lines, and for each line I need to extract different sections of text, then write several variables from the data. I can split out the various sections by selecting their position on each line as the column sizes will never vary. A sample of my text file is below... (2 Replies)
Discussion started by: kcpoole
2 Replies

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

8. Shell Programming and Scripting

Extract a part of variable/line content in a file

I have a variable and assigned the following values ***XYZ_201519_20150929140642_20150929140644_211_0_0_211 I need to read this variable from backward and stop read when I get first underscore (_) In this scenario I should get 211 Thanks Kris (3 Replies)
Discussion started by: mkris
3 Replies

9. Shell Programming and Scripting

Bash to extract file prefix and from input to use in output

In the bash below which does execute I am trying to extract the contents of ${id} is 1234, as ${id} stores the variable that changes each time. After the path is removed the contents of ${id} are stored in pref, so they can be used in the output. Currently I am not able to extract the 1234 in the... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. UNIX for Beginners Questions & Answers

Extract file names from file and set variable to 'highest' one

HI Folks - I have a requirement where I need to scan a text file for a list of files. The file, we'll called it, files.txt looks like such: inbox/EBS/Client_GL_Detail_PBCS_112517_SEP2017.txt inbox/EBS/Client_GL_Detail_PBCS_112617_NOV2017.txt ... (9 Replies)
Discussion started by: SIMMS7400
9 Replies
JOCAML(1)						      General Commands Manual							 JOCAML(1)

NAME
jocaml - The JoCaml interactive toplevel SYNOPSIS
jocaml [ -unsafe ] [ -I lib-dir ] [ object-files ] [ script-file ] DESCRIPTION
The jocaml(1) command is the toplevel system for JoCaml, that permits interactive use of the JoCaml system through a read-eval-print loop. In this mode, the system repeatedly reads Caml phrases from the input, then typechecks, compiles and evaluates them, then prints the inferred type and result value, if any. The system prints a # (sharp) prompt before reading each phrase. A toplevel phrase can span several lines. It is terminated by ;; (a double-semicolon). The syntax of toplevel phrases is as follows. The toplevel system is started by the command jocaml(1). Phrases are read on standard input, results are printed on standard output, errors on standard error. End-of-file on standard input terminates jocaml(1). If one or more object-files (ending in .cmo or .cma ) are given, they are loaded silently before starting the toplevel. If a script-file is given, phrases are read silently from the file, errors printed on standard error. jocaml(1) exits after the execution of the last phrase. OPTIONS
The following command-line options are recognized by jocaml(1). -I directory Add the given directory to the list of directories searched for source and compiled files. By default, the current directory is searched first, then the standard library directory. Directories added with -I are searched after the current directory, in the order in which they were given on the command line, but before the standard library directory. -unsafe Turn bound checking off on array and string accesses (the v.(i) and s.[i] constructs). Programs compiled with -unsafe are therefore slightly faster, but unsafe: anything can happen if the program accesses an array or string outside of its bounds. ENVIRONMENT VARIABLES
LC_CTYPE If set to iso_8859_1, accented characters (from the ISO Latin-1 character set) in string and character literals are printed as is; otherwise, they are printed as decimal escape sequences. TERM When printing error messages, the toplevel system attempts to underline visually the location of the error. It consults the TERM variable to determines the type of output terminal and look up its capabilities in the terminal database. SEE ALSO
jocamlc(1). The Objective Caml user's manual, chapter "The toplevel system". JOCAML(1)
All times are GMT -4. The time now is 02:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy