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 funcname ( arguments ) DESCRIPTION
CREATE TRIGGER creates a new trigger. The trigger will be associated with the specified table and will execute the specified function func- name when certain events occur. The trigger can be specified to fire either before the operation is attempted on a row (before constraints are checked and the INSERT, UPDATE, or DELETE is attempted) or after the operation has completed (after constraints are checked and the INSERT, UPDATE, or DELETE has completed). If the trigger fires before the event, the trigger can skip the operation for the current row, or change the row being inserted (for INSERT and UPDATE operations only). If the trigger fires after the event, all changes, including the last insertion, update, or dele- tion, are ``visible'' to the trigger. A trigger that is marked FOR EACH ROW is called once for every row that the operation modifies. For example, a DELETE that affects 10 rows will cause any ON DELETE triggers on the target relation to be called 10 separate times, once for each deleted row. In contrast, a trigger that is marked FOR EACH STATEMENT only executes once for any given operation, regardless of how many rows it modifies (in particular, an operation that modifies zero rows will still result in the execution of any applicable FOR EACH STATEMENT triggers). In addition, triggers may be defined to fire for a TRUNCATE, though only FOR EACH STATEMENT. 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 cannot create SELECT triggers. Rules and views are more appropriate in such cases. Refer to in the documentation for more information about triggers. PARAMETERS
name The name to give the new trigger. This must be distinct from the name of any other trigger for the same table. BEFORE AFTER Determines whether the function is called before or after the event. event One of INSERT, UPDATE, DELETE, or TRUNCATE; this specifies the event that will fire the trigger. Multiple events can be specified using OR. table The name (optionally schema-qualified) of the table the trigger is for. FOR EACH ROW FOR EACH STATEMENT This specifies whether the trigger procedure should be fired once for every row affected by the trigger event, or just once per SQL statement. If neither is specified, FOR EACH STATEMENT is the default. funcname A user-supplied function that is declared as taking no arguments and returning type trigger, which is executed when the trigger fires. arguments An optional comma-separated list of arguments to be provided to the function when the trigger is executed. The arguments are literal string constants. Simple names and numeric constants can be written here, too, but they will all be converted to strings. Please check the description of the implementation language of the trigger function about how the trigger arguments are accessible within the function; it might be different from normal function arguments. NOTES
To create a trigger on a table, the user must have the TRIGGER privilege on the table. Use DROP TRIGGER [drop_trigger(7)] to remove a trigger. 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. EXAMPLES
in the documentation contains a complete example. COMPATIBILITY
The CREATE TRIGGER statement in PostgreSQL implements a subset of the SQL standard. The following functionality is currently missing: o SQL allows triggers to fire on updates to specific columns (e.g., AFTER UPDATE OF col1, col2). o SQL allows you to define aliases for the ``old'' and ``new'' rows or tables for use in the definition of the triggered action (e.g., CRE- ATE 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 allows the execution of a user-defined function for the triggered action. The standard allows the execution of a number of other SQL commands, such as CREATE TABLE as the triggered action. This limitation is not hard to work around by creating a user- defined function that executes the desired commands. SQL specifies that multiple triggers should be fired in time-of-creation order. PostgreSQL uses name order, which was judged to be more convenient. SQL specifies that BEFORE DELETE triggers on cascaded deletes fire after the cascaded DELETE completes. The PostgreSQL behavior is for BEFORE DELETE to always fire before the delete action, even a cascading one. This is considered more consistent. There is also unpre- dictable behavior when BEFORE triggers modify rows that are later to be modified by referential actions. This can lead to constraint viola- tions or stored data that does not honor the referential constraint. The ability to specify multiple actions for a single trigger using OR is a PostgreSQL extension of the SQL standard. The ability to fire triggers for TRUNCATE is a PostgreSQL extension of the SQL standard. SEE ALSO
CREATE FUNCTION [create_function(7)], ALTER TRIGGER [alter_trigger(7)], DROP TRIGGER [drop_trigger(7)] SQL - Language Statements 2010-05-14 CREATE TRIGGER(7)
All times are GMT -4. The time now is 01:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy