Sponsored Content
Full Discussion: Replace last n lines
Top Forums Shell Programming and Scripting Replace last n lines Post 303028044 by onenessboy on Sunday 30th of December 2018 07:28:26 AM
Old 12-30-2018
Quote:
Originally Posted by onenessboy
Hi Ravinder,

I tried your solution here is what it displays..
stlib='smb_static bsd z resolv rt' this line still shows..
Code:
[root@xx-xx--xxx source]# tac reptest | awk 'FNR!=2 && FNR!=3' | tac
if bld.env.SAMBA_DIR:
    bld.program(target='winexe-static',
        source='winexe.c svcinstall.c async.c winexesvc32_exe.c winexesvc64_exe.c',
        includes=bld.env.SAMBA_DIR + '/bin/default/include/public',
        cflags='-pthread -include ' + bld.env.SAMBA_DIR + '/bin/default/include/config.h',
        linkflags='-pthread',
        stlibpath=bld.srcnode.abspath() + '/smb_static/build',
        stlib='smb_static bsd z resolv rt',

mean while i am trying head command too...let you know result
Ok, as of now I figured it out with different command that is head -n to remove last 3 lines and append new lines with >>

Code:
[root@ip-xxxxx source]# head -n -3 reptest > tmp.txt && cp tmp.txt reptest
cp: overwrite ‘reptest'? y
[root@ip-xxxxxx source]# echo -e '\t'"stlib='smb_dynamic bsd z resolv rt'", >> reptest
[root@ip-xxxxxx source]# echo -e '\t'"lib='dl ls'", >> reptest
[root@ip-xxxxxx source]# echo -e '\t'")" >> reptest
[root@ip-xxxxx source]# cat reptest
if bld.env.SAMBA_DIR:
    bld.program(target='winexe-static',
        source='winexe.c svcinstall.c async.c winexesvc32_exe.c winexesvc64_exe.c',
        includes=bld.env.SAMBA_DIR + '/bin/default/include/public',
        cflags='-pthread -include ' + bld.env.SAMBA_DIR + '/bin/default/include/config.h',
        linkflags='-pthread',
        stlibpath=bld.srcnode.abspath() + '/smb_static/build',
        stlib='smb_dynamic bsd z resolv rt',
        lib='dl ls',
        )

This User Gave Thanks to onenessboy For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED - Search and replace lines containing...

Hi, I need a sed line that will find all lines that contain "<int key="NSWindowStyleMask">" and then replace the entire line (not just that one string) with "<int key="NSWindowStyleMask">8223</int>". It doesn't necessarily have to use sed as long as it gets the job done :) Thanks (9 Replies)
Discussion started by: pcwiz
9 Replies

2. Shell Programming and Scripting

replace lines in a file

I've got a file full of numbers, example: cat test.file 60835287 0 51758036 40242437 0 32737144 0 24179513 0 4131489957 I want to replace those numbers (4 Replies)
Discussion started by: TehOne
4 Replies

3. Shell Programming and Scripting

sed to replace two lines with one

I want to use sed to check if a short line is contained in the line after it, and if it is, to delete the short one. In other words, the input is... This is a This is a line ... and I want it to give me... This is a line Here's what I've tried so far: s/\(^.*\)\n\(\1.*$\)/\2/ Also,... (7 Replies)
Discussion started by: estebandido
7 Replies

4. Shell Programming and Scripting

Replace lines from one file to another

Hello, I have 8 lines containing these unique words in both files 645147468537 673962863160 673962864957 691717701950 707917019907 790085591726 792975507744 852174812753 file.dat.orig (has 1000 lines) and file.dat(has only 8 lines) I want to replace those lines in file.dat.orig by... (1 Reply)
Discussion started by: jakSun8
1 Replies

5. Shell Programming and Scripting

Replace lines in a file

Hi everybody, I am a newbie in shell scripting and I'm trying to write a script which reads lines from a file, searching some of this lines to change a specified number. I want to replace the line for another in the file. I have to replace multiples lines, so I have a for. Now I am trying with... (1 Reply)
Discussion started by: alex82
1 Replies

6. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

7. Shell Programming and Scripting

Find and Replace Different Lines

Hi, I am looking at modifiying a file but getting a bit lost with what i am trying to do. I have the following file i need to alter. I want to search a list of files for the DEVSERIAL "0007862454" part but only the numbers. I then need to replace the line under DRIVES with the correct drive... (7 Replies)
Discussion started by: forcefullpower
7 Replies

8. Shell Programming and Scripting

[sed] Replace one line with two lines

Literally cannot get this one, guys. Single line replacement is simple, but I am not understanding the correct syntax for including a new line feed into the substitution part. Here's what I got. (Cannot use perl) #!/bin/sh set -f #Start Perms export HOME=/home/test_user # End Perms... (6 Replies)
Discussion started by: Parallax
6 Replies

9. UNIX for Dummies Questions & Answers

How can I replace the lines that start with a star and replace it with numbers start from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example > this file contain a list * linux * computers * labs * questions to >>>> this file contain a list 1. linux 2. computers 3. labs 4. questions (7 Replies)
Discussion started by: aalbazie
7 Replies

10. UNIX for Dummies Questions & Answers

Replace character in odd or even lines

Hello, I'm here again asking for your precious help. I'm writing some code to convert csv files to html. I want to highlight header and also I want to have rows with alternate colors. So far this is my work###Let's format first line only with some color cat $fileIN".tmp1" | sed '1... (7 Replies)
Discussion started by: emare
7 Replies
DH-EXEC(1)							      dh-exec								DH-EXEC(1)

NAME
dh-exec - Debhelper executable file helpers SYNOPSIS
#! /usr/bin/dh-exec src/libfoo-*.so.* debian/foo-plugins/usr/lib/foo/${DEB_HOST_MULTIARCH}/ etc/example.conf => debian/foo/etc/foo/foo.conf DESCRIPTION
dh-exec is a simple program, meant to be used as the interpreter for executable debhelper config files. It is a wrapper around the various other sub-commands (see below), and will pipe the input file through all of them in turn, using an ordering that makes most sense in the vast majority of cases. The order as of now is dh-exec-subst gets run first, followed by dh-exec-install, so that variable expansion happens before files need to be copied. ARCHITECTURE
dh-exec is built up from three layers: there is the dh-exec utility, its single entry point, the only thing one will need to call. Below that, there are the various sub-commands, such as dh-exec-subst, dh-exec-installs and dh-exec-illiterate, which are thin wrappers around the various dh-exec scripts, that make sure they only run those that need to be run. And the lowest layer are the various scripts that do the actual work. One can control which sub-commands to run, or if even more granularity is desired, one can limit which scripts shall be run, too. See below for the options! OPTIONS
--with=command[,command ...] Replace the list of sub-commands to run the input through with a custom list (where entries are separated by whitespace or commas). This option will always replace the existing list with whatever is specified. This can be used to explicitly set which sub-commands to use. The list must not include the dh-exec- prefix. Defaults to subst,install. --without=command[,command ...] Inversely to the option above, this lists all the sub-commands which should not be used. The list must not include the dh-exec- prefix. --with-scripts=script[,script ...] Replace the list of scripts to run the input through with a custom list (where entries are separated by whitespace or commas). This option will always replace the existing list with whatever is specified. This can be used to explicitly specify which scripts to use, limiting even beyond what the --with option is capable of. The list must not include the dh-exec- prefix. By default it is empty, meaning there is no filtering done, and whatever scripts the sub-commands find, will be run. --no-act Do not really do anything, but print the pipeline that would have been run instead. --list List the available sub-commands and scripts, grouped by sub-command. --help, --version Display a short help or the package version, respectively. SUB-COMMANDS dh-exec-subst Substitutes various variables (either from the environment, or from dpkg-architecture(1)). dh-exec-install An extension to dh_install(1), that supports renaming files during the copy process, using a special syntax. ENVIRONMENT
DH_EXEC_LIBDIR The directory in which the wrapped sub-commands reside. Defaults to /usr/lib/dh-exec/. DH_EXEC_SCRIPTDIR The directory in which the scripts that do the heavy work live. Defaults to /usr/share/dh-exec/. FILES
$DH_EXEC_LIBDIR/dh-exec-* The various sub-commands. $DH_EXEC_SCRIPTDIR/dh-exec-* The various scripts ran by the sub-commands. SEE ALSO
debhelper(1), dh-exec-subst(1), dh-exec-install(1) AUTHOR
dh-exec is copyright (C) 2011-2012 by Gergely Nagy <algernon@madhouse-project.org>. 2012-05-03 DH-EXEC(1)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy