Sponsored Content
Top Forums Shell Programming and Scripting Reading text file, comparing a value in a line, and placing only part of the line in a variable? Post 302840783 by xChristopher on Tuesday 6th of August 2013 12:27:47 PM
Old 08-06-2013
Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file.

Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01.

Is this possible? any help is appreciated.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading text file line by line

Ok. before anyone mentions it, I did search for this but I'm not sure if I am looking for the right thing. Now, onto my issue. I have been keeping vmstats output in running text files. So I have a file that looks like this: vmstat 2 5 2005.09.19 kthr memory page ... (6 Replies)
Discussion started by: MizzGail
6 Replies

2. Shell Programming and Scripting

Reading data from a specific line in a text file

hello, I have got the following problem that I am hoping someone can help with please. 1. I have got the following text file (below) , the columns data are 'Test Day', 'Board', 'Betting Number'. TEXT FILE ============================================ 1 3 02-01-27-28-29-30 0 1... (1 Reply)
Discussion started by: jermaine4ever
1 Replies

3. Shell Programming and Scripting

reading the whole line from a file into a variable

Hi, I am doing : while read line do printf "%s\n" ${line} done <datafile.txt but I am not getting each single line from the data file assigned to the variable line (but only tokens/fields at a time). I also tried while IFS= read -r lineI want the whole line assigned or read into the... (2 Replies)
Discussion started by: shri_nath
2 Replies

4. Shell Programming and Scripting

Insertion New line whilst reading the text file

Hi, For the text file let us say t.txt having the statements as below. filename : t.txt. Contents : This is first string1 This is first string2 This is first string3 The output of the file should have newline. How to introduce the new line so that the output be as follows ... (5 Replies)
Discussion started by: krackjack
5 Replies

5. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

6. Shell Programming and Scripting

reading line by line from a text file

Hi, I have a text file something like this: 10.10.10.1, ldap, cn=users,dc=example,dc=com ..... ... and many more lines ... ... now i want to read each individual line from the file and assign it to a variable example: the script should read 10.10.10.1 and assign it to a variable say... (3 Replies)
Discussion started by: sunrexstar
3 Replies

7. UNIX for Dummies Questions & Answers

Parsing file, reading each line to variable, evaluating date/time stamp of each line

So, the beginning of my script will cat & grep a file with the output directed to a new file. The data I have in this file needs to be parsed, read and evaluated. Basically, I need to identify the latest date/time stamp and then calculate whether or not it is within 15 minutes of the current... (1 Reply)
Discussion started by: hynesward
1 Replies

8. Shell Programming and Scripting

EXPECT: Assign variable by reading a line of text from a file

Hi All, I have been using a program on windows called AutoKey. My environment at work is Linux and I have been experimenting with expect. Very powerful. I can move my AutoKey scripts to Linux using Expect once I am educated on how to read from a file using Expect. My application would be... (1 Reply)
Discussion started by: quemalr
1 Replies

9. 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
CREATE 
TRIGGER(7) SQL Commands CREATE TRIGGER(7) NAME
CREATE TRIGGER - define a new trigger SYNOPSIS
CREATE TRIGGER name { BEFORE | AFTER } { event [OR ...] } ON table FOR EACH { ROW | STATEMENT } EXECUTE PROCEDURE func ( arguments ) INPUTS name The name to give the new trigger. This must be distinct from the name of any other trigger for the same table. event One of INSERT, DELETE or UPDATE. table The name (optionally schema-qualified) of the table the trigger is for. func A user-supplied function that is declared as taking no arguments and returning type trigger. arguments An optional comma-separated list of arguments to be provided to the function when the trigger is executed, along with the standard trigger data such as old and new tuple contents. The arguments are literal string constants. Simple names and numeric constants may be written here too, but they will all be converted to strings. OUTPUTS CREATE TRIGGER This message is returned if the trigger is successfully created. DESCRIPTION
CREATE TRIGGER will enter a new trigger into the current data base. The trigger will be associated with the relation table and will execute the specified function func. The trigger can be specified to fire either before BEFORE the operation is attempted on a tuple (before constraints are checked and the INSERT, UPDATE or DELETE is attempted) or AFTER the operation has been attempted (e.g., after constraints are checked and the INSERT, UPDATE or DELETE has completed). If the trigger fires before the event, the trigger may skip the operation for the current tuple, or change the tuple being inserted (for INSERT and UPDATE operations only). If the trigger fires after the event, all changes, including the last insertion, update, or deletion, are ``visible'' to the trigger. If multiple triggers of the same kind are defined for the same event, they will be fired in alphabetical order by name. SELECT does not modify any rows so you can not create SELECT triggers. Rules and views are more appropriate in such cases. Refer to the chapters on SPI and Triggers in the PostgreSQL Programmer's Guide for more information. NOTES
To create a trigger on a table, the user must have the TRIGGER privilege on the table. In PostgreSQL versions before 7.3, it was necessary to declare trigger functions as returning the placeholder type opaque, rather than trigger. To support loading of old dump files, CREATE TRIGGER will accept a function declared as returning opaque, but it will issue a NOTICE and change the function's declared return type to trigger. As of the current release, STATEMENT triggers are not implemented. Refer to the DROP TRIGGER [drop_trigger(7)] command for information on how to remove triggers. EXAMPLES
Check if the specified distributor code exists in the distributors table before appending or updating a row in the table films: CREATE TRIGGER if_dist_exists BEFORE INSERT OR UPDATE ON films FOR EACH ROW EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did'); Before cancelling a distributor or updating its code, remove every reference to the table films: CREATE TRIGGER if_film_exists BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did'); The second example can also be done by using a foreign key, constraint as in: CREATE TABLE distributors ( did DECIMAL(3), name VARCHAR(40), CONSTRAINT if_film_exists FOREIGN KEY(did) REFERENCES films ON UPDATE CASCADE ON DELETE CASCADE ); COMPATIBILITY
SQL92 There is no CREATE TRIGGER statement in SQL92. SQL99 The CREATE TRIGGER statement in PostgreSQL implements a subset of the SQL99 standard. The following functionality is missing: o SQL99 allows triggers to fire on updates to specific columns (e.g., AFTER UPDATE OF col1, col2). o SQL99 allows you to define aliases for the ``old'' and ``new'' rows or tables for use in the definition of the triggered action (e.g., CREATE TRIGGER ... ON tablename REFERENCING OLD ROW AS somename NEW ROW AS othername ...). Since PostgreSQL allows trigger procedures to be written in any number of user-defined languages, access to the data is handled in a language-specific way. o PostgreSQL only has row-level triggers, no statement-level triggers. o PostgreSQL only allows the execution of a stored procedure for the triggered action. SQL99 allows the execution of a number of other SQL commands, such as CREATE TABLE as triggered action. This limitation is not hard to work around by creating a stored procedure that executes these commands. SQL99 specifies that multiple triggers should be fired in time-of-creation order. PostgreSQL uses name order, which was judged more conve- nient to work with. SEE ALSO
CREATE FUNCTION [create_function(7)], ALTER TRIGGER [alter_trigger(l)], DROP TRIGGER [drop_trigger(l)], PostgreSQL Programmer's Guide SQL - Language Statements 2002-11-22 CREATE TRIGGER(7)
All times are GMT -4. The time now is 04:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy