Sponsored Content
Top Forums Shell Programming and Scripting Append text from one file to another based on a search from the end of a document Post 302464656 by vgersh99 on Wednesday 20th of October 2010 04:30:15 PM
Old 10-20-2010
something to start with:
Code:
nawk '/\$HESS/ {arr="";f=1} f {arr=(arr)?arr ORS $0:$0} /\$END/{f=0} END {print arr}' job_input.dat

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append a field to the end of each line of a file based on searching another file.

Hi All, I have two comma separated value(CSV) files, say FileA and FileB. The contents looks like that shown below. FileA EmpNo,Name,Age,Sex, 1000,ABC,23,M, 1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies

2. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

3. Shell Programming and Scripting

search directory-find files-append at end of line

Hi, I have a command "get_data" with some parameters in few *.text files of a directory. I want to first find those files that contain this command and then append the following parameter to the end of the command. example of an entry in the file :- get_data -x -m50 /etc/web/getid this... (1 Reply)
Discussion started by: PrasannaKS
1 Replies

4. Shell Programming and Scripting

append some text message at the end of the file

Hi All, Please tell me how to append some text message at the end of the file. "File too large to view" example: xyz.log contains hhhhhhhhhhh hhhhhhjjjjjjjjj jjjjjjjjjjjjjjjjjjjjjj "File too large to view" Please advice (3 Replies)
Discussion started by: rajeshorpu
3 Replies

5. UNIX for Dummies Questions & Answers

How can I append a text at end of file after displaying the file

I have a file "sample.txt" with the content as below: Hi This is a Sample Text. I need a single command using cat which serve the following purpose. 1.display the contents of sample.txt 2.append some text to it 3. and then exit But, all should be served by a sinle command.:confused: (1 Reply)
Discussion started by: g.ashok
1 Replies

6. Shell Programming and Scripting

Append the text file with comma at the end of every word

Hi folks, Using shell, I am trying the append comma to every line of text. the requirement is like, I have to open the txt file in unix and read line by line and should add comma at the end of every word to make it single line txt file ------- abc@gmail.com bcd@gmail.com... (7 Replies)
Discussion started by: giridhar276
7 Replies

7. Shell Programming and Scripting

Search for a string, then append character to end of that line only

I have 2 files that I am working with $ cat file1 server1 server3 server5 server6 server8 $ cat file2 server1;Solaris; server2; SLES; server3;Linux; server4; Solaris; server5;SLES; server6;SLES; server7;Solaris; server8;Linux; (1 Reply)
Discussion started by: snoman1
1 Replies

8. Shell Programming and Scripting

To append new data at the end of each line based on substring of last column

Hi guys, I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column. Input file xxx.csv: U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0 U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Discussion started by: null7
5 Replies

9. Shell Programming and Scripting

sed - go to file and search a part and set at the end text

Hello, i hope the titel is okay. I want to edit a line in /etc/arno-iptables-firewall/firewall.conf So the Line can contains: OPEN_TCP="436, 25, 80, 110, 143, 443, 465, 587, 993, 995, 21, 20" i want to search in this line: OPEN_TCP="*, *, 80, *, *, 443, *, *, *, *" and i want to... (11 Replies)
Discussion started by: tJAdASwIRDESSEI
11 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to append multiple text files into one file based on pattern present in filaname

Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames? AAAL_555A_ORANGE1_F190404.TXT AAAL_555A_ORANGE2_F190404.TXT AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies
QUEUE_SPLITTER(1)														 QUEUE_SPLITTER(1)

NAME
queue_splitter - PgQ consumer that transports events from one queue into several target queues SYNOPSIS
queue_splitter.py [switches] config.ini DESCRIPTION
queue_spliter is PgQ consumer that transports events from source queue into several target queues. ev_extra1 field in each event shows into which target queue it must go. (pgq.logutriga() puts there the table name.) One use case is to move events from OLTP database to batch processing server. By using queue spliter it is possible to move all kinds of events for batch processing with one consumer thus keeping OLTP database less crowded. QUICK-START Basic queue_splitter setup and usage can be summarized by the following steps: 1. pgq must be installed both in source and target databases. See pgqadm man page for details. Target database must also have pgq_ext schema installed. 2. edit a queue_splitter configuration file, say queue_splitter_sourcedb_sourceq_targetdb.ini 3. create source and target queues $ pgqadm.py ticker.ini create <queue> 4. launch queue splitter in daemon mode $ queue_splitter.py queue_splitter_sourcedb_sourceq_targetdb.ini -d 5. start producing and consuming events CONFIG
Common configuration parameters job_name Name for particulat job the script does. Script will log under this name to logdb/logserver. The name is also used as default for PgQ consumer name. It should be unique. pidfile Location for pid file. If not given, script is disallowed to daemonize. logfile Location for log file. loop_delay If continuisly running process, how long to sleep after each work loop, in seconds. Default: 1. connection_lifetime Close and reconnect older database connections. log_count Number of log files to keep. Default: 3 log_size Max size for one log file. File is rotated if max size is reached. Default: 10485760 (10M) use_skylog If set, search for [./skylog.ini, ~/.skylog.ini, /etc/skylog.ini]. If found then the file is used as config file for Pythons logging module. It allows setting up fully customizable logging setup. Common PgQ consumer parameters pgq_queue_name Queue name to attach to. No default. pgq_consumer_id Consumers ID to use when registering. Default: %(job_name)s queue_splitter parameters src_db Source database. dst_db Target database. Example config file [queue_splitter] job_name = queue_spliter_sourcedb_sourceq_targetdb src_db = dbname=sourcedb dst_db = dbname=targetdb pgq_queue_name = sourceq logfile = ~/log/%(job_name)s.log pidfile = ~/pid/%(job_name)s.pid COMMAND LINE SWITCHES
Following switches are common to all skytools.DBScript-based Python programs. -h, --help show help message and exit -q, --quiet make program silent -v, --verbose make program more verbose -d, --daemon make program go background Following switches are used to control already running process. The pidfile is read from config then signal is sent to process id specified there. -r, --reload reload config (send SIGHUP) -s, --stop stop program safely (send SIGINT) -k, --kill kill program immidiately (send SIGTERM) USECASE
How to to process events created in secondary database with several queues but have only one queue in primary database. This also shows how to insert events into queues with regular SQL easily. CREATE SCHEMA queue; CREATE TABLE queue.event1 ( -- this should correspond to event internal structure -- here you can put checks that correct data is put into queue id int4, name text, -- not needed, but good to have: primary key (id) ); -- put data into queue in urlencoded format, skip actual insert CREATE TRIGGER redirect_queue1_trg BEFORE INSERT ON queue.event1 FOR EACH ROW EXECUTE PROCEDURE pgq.logutriga('singlequeue', 'SKIP'); -- repeat the above for event2 -- now the data can be inserted: INSERT INTO queue.event1 (id, name) VALUES (1, 'user'); If the queue_splitter is put on "singlequeue", it spreads the event on target to queues named "queue.event1", "queue.event2", etc. This keeps PgQ load on primary database minimal both CPU-wise and maintenance-wise. 03/13/2012 QUEUE_SPLITTER(1)
All times are GMT -4. The time now is 06:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy