Sponsored Content
Top Forums Shell Programming and Scripting Match text to lines in a file, iterate backwards until text or text substring matches, print to file Post 303038372 by Neo on Sunday 1st of September 2019 05:30:06 AM
Old 09-01-2019
Our general policy is for everyone here to "try and write their own script first" and then post what you tried.

Sometimes, our members forget and respond like a "script writing service"; but that is not our policy.

So please post the code you tried to write "on your own" and any error messages you got.

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print only certain lines from a text file

Hi all, I have a text file and I want to clean up the file by only print those lines start with the date. Is there anyway I can do that?  Thanks CT (1 Reply)
Discussion started by: CamTu
1 Replies

2. Shell Programming and Scripting

Search text from a file and print text and one previous line too

Hi, Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11 Thanks for your help. (6 Replies)
Discussion started by: kamranjalal
6 Replies

3. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

4. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

5. Shell Programming and Scripting

How to delete lines of a text file based on another text file?

I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries. The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies

6. Shell Programming and Scripting

Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this > sat#16 #data: 15 site:UNZA baseline: 205.9151 0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722 0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies

7. Shell Programming and Scripting

Match text and print/pipe only that text

I'm trying to pull an image source url from a html source file. I'm new with regex. I'm in BaSH. I've tried grep -E 'http.*jpg' file which highlights the text, but gives me 2 problems: 1) Results aren't stand alone and can't be piped to another command. (I believe it includes everything in... (5 Replies)
Discussion started by: amx401
5 Replies

8. Shell Programming and Scripting

Match text from file 1 to file 2 and return specific text

I hope this makes sense and is possible. I am trying to match $1 of panel_genes.txt with $3 of RefSeqGene.txt and when a match is found the value in $6 of RefSeqGene.txt Example: ACTA2 is $1 of panel_genes.txt ACTA2 NM_001613.2 ACTA2 NM_001141945.1 awk 'FNR==NR {... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Using awk to remove lines from file that match text

I am trying to remove each line in which $2 is FP or RFP. I believe the below will remove one instance but not both. Thank you :). file 12 123 FP 11 10 RFP awk awk -F'\t' ' $2 != "FP"' file desired output 12 11 (6 Replies)
Discussion started by: cmccabe
6 Replies

10. Shell Programming and Scripting

Match all lines in file where specific text pattern is less than

In the below file I am trying to grep or similar, all lines where only AF= is less than 0.4.. Thank you :). grep grep "AF=" ,+ .4 file file 12 112036782 . T C 34.0248 PASS ... (3 Replies)
Discussion started by: cmccabe
3 Replies
INVOKE-RC.D(8)                                                   Debian GNU/Linux                                                   INVOKE-RC.D(8)

NAME
invoke-rc.d - executes System-V style init script actions SYNOPSIS
invoke-rc.d [--quiet] [--force] [--try-anyway] [--disclose-deny] [--query] [--no-fallback] name action [init script parameters...] invoke-rc.d [--help] DESCRIPTION
invoke-rc.d is a generic interface to execute System V style init script /etc/init.d/name actions, obeying runlevel constraints as well as any local policies set by the system administrator. All access to the init scripts by Debian packages' maintainer scripts should be done through invoke-rc.d. This manpage documents only the usage and behavior of invoke-rc.d. For a discussion of the System V style init script arrangements please see init(8). More information on invoke-rc.d can be found in the section on runlevels and init.d scripts of the Debian Policy Manual. INIT SCRIPT ACTIONS
The standard actions are: start, stop, force-stop, restart, try-restart, reload, force-reload, and status. Other actions are accepted, but they can cause problems to policy-rc.d (see the INIT SCRIPT POLICY section), so warnings are generated if the policy layer is active. Please note that not all init scripts will implement all the actions listed above, and that the policy layer may override an action to another action(s), or even deny it. Any extra parameters will be passed to the init script(s) being executed. If an action must be carried out regardless of any local policies, use the --force switch. OPTIONS
--help Display usage help. --quiet Quiet mode, no error messages are generated. --force Tries to run the init script regardless of policy and init script subsystem errors. Use of this option in Debian maintainer scripts is severely discouraged. --try-anyway Tries to run the init script if a non-fatal error is detected. --disclose-deny Return status code 101 instead of status code 0 if the init script action is denied by the policy layer. --query Returns one of the status codes 100-106. Does not run the init script, and implies --disclose-deny and --no-fallback. --no-fallback Ignores any fallback action requests by the policy layer. Warning: this is usually a very bad idea for any actions other than start. STATUS CODES
Should an init script be executed, invoke-rc.d always returns the status code returned by the init script. Init scripts should not return status codes in the 100+ range (which is reserved in Debian and by the LSB). The status codes returned by invoke-rc.d proper are: 0 Success. Either the init script was run and returned exit status 0 (note that a fallback action may have been run instead of the one given in the command line), or it was not run because of runlevel/local policy constrains and --disclose-deny is not in effect. 1 - 99 Reserved for init.d script, usually indicates a failure. 100 Init script ID (name) unknown. This means the init script was not registered successfully through update-rc.d or that the init script does not exist. 101 Action not allowed. The requested action will not be performed because of runlevel or local policy constraints. 102 Subsystem error. Init script (or policy layer) subsystem malfunction. Also, forced init script execution due to --try-anyway or --force failed. 103 Syntax error. 104 Action allowed. Init script would be run, but --query is in effect. 105 Behavior uncertain. It cannot be determined if action should be carried out or not, and --query is in effect. 106 Fallback action requested. The policy layer denied the requested action, and supplied an allowed fallback action to be used instead. INIT SCRIPT POLICY
invoke-rc.d introduces the concept of a policy layer which is used to verify if an init script should be run or not, or if something else should be done instead. This layer has various uses, the most immediate ones being avoiding that package upgrades start daemons out-of-runlevel, and that a package starts or stops daemons while inside a chroot jail. The policy layer has the following abilities: deny or approve the execution of an action; request that another action (called a fallback) is to be taken, instead of the action requested in invoke-rc.d's command line; or request multiple actions to be tried in order, until one of them succeeds (a multiple fallback). invoke-rc.d itself only pays attention to the current runlevel; it will block any attempts to start a service in a runlevel in which the service is disabled. Other policies are implemented with the use of the policy-rc.d helper, and are only available if /usr/sbin/pol- icy-rc.d is installed in the system. FILES
/etc/init.d/* System V init scripts. /usr/sbin/policy-rc.d Init script policy layer helper (not required). /etc/runlevel.conf file-rc runlevel configuration (if the file-rc package is being used). /etc/rc?.d/* System V runlevel configuration (if the sysv-rc package is being used). NOTES
invoke-rc.d special cases the status action, and returns exit status 4 instead of exit status 0 when it is denied. BUGS
Please report any bugs using the Debian bug tracking system, http://bugs.debian.org/, package sysv-rc or file-rc (depending on which ver- sion of invoke-rc.d you are using). SEE ALSO
Debian Policy manual, /etc/init.d/skeleton, update-rc.d(8), init(8), /usr/share/doc/init-system-helpers/README.policy-rc.d.gz AUTHOR
Henrique Holschuh Licence: GNU Public Licence v2 or Later (GPLv2+) COPYRIGHT
2001 Hernique Holschuh 1 March 2001 INVOKE-RC.D(8)
All times are GMT -4. The time now is 04:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy