Sponsored Content
Top Forums Shell Programming and Scripting Remove previous line if next & previous lines have same 4th character. Post 302728983 by Raza Ali on Thursday 8th of November 2012 10:19:01 PM
Old 11-08-2012
Thanx rdrtx1 , but problem is tac is not working in my system.

The above cat abc_do_it output is taken from one of one line command , I want to use |after that and then get the desired result.

tgstats `trunkgroups g | egrep "mtn|grp|rpk|nwt" | awk '{print $1}' | sort -u` | egrep -v Totals | egrep "^[mtn|grp|rpk|nwt]|\% \(" > abc_do_it

I want to use tgstats `trunkgroups g | egrep "mtn|grp|rpk|nwt" | awk '{print $1}' | sort -u` | egrep -v Totals | egrep "^[mtn|grp|rpk|nwt]|\% \(" | some_command_to_get_desired_output.


AWK logic is very good , its working but tac is not present in my system and I am not system admin.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use sed to search for string and Print previous two lines and current line

Hello, Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line. i am using string as "testing" netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h i am able to get the previous line current line next line but... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

2. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

3. Shell Programming and Scripting

print range of lines matching pattern and previous line

Hi all, on Solaris 10, I'd like to print a range of lines starting at pattern but also including the very first line before pattern. the following doesn't print the range starting at pattern and going down to the end of file: cat <my file> | sed -n -e '/<pattern>{x;p;}/' I need to include the... (1 Reply)
Discussion started by: siriche
1 Replies

4. Shell Programming and Scripting

Append next line to previous lines when NF is less than 0

Hi All, This is very urgent, I've a data file with 1.7 millions rows in the file and the delimiter is cedilla and I need to format the data in such a way that if the NF in the next row is less than 1, it will append that value to previous line. Any help will be appricated. Thanks,... (17 Replies)
Discussion started by: cumeh1624
17 Replies

5. UNIX for Dummies Questions & Answers

How to remove fields space and append next line to previous line.?

awk 'BEGIN{FS = "Ç"} NR == 1 {p = $0; next} NF > 1 {print p; p = $0} NF <= 1 {p = (p " " $0)} END {print p}' input.txt > output.txt This is what the input data file looks like with broken lines Code: 29863 Ç890000000 Ç543209911 ÇCHNGOHG Ç000000001 Ç055 ... (4 Replies)
Discussion started by: cumeh1624
4 Replies

6. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

7. Shell Programming and Scripting

Returning multiple outputs of a single line based on previous repeated lines

Hello, I am trying to return a time multiple times from a file that has varying output just before the time instance, i.e. cat jumped cat jumped cat jumped time = 1.1 cat jumped cat jumped time = 1.2 cat jumped cat jumped time = 1.3 In this case i would like to output a time.txt... (6 Replies)
Discussion started by: ryddner
6 Replies

8. Shell Programming and Scripting

Sed: how to merge two lines moving matched pattern to end of previous line

hello everyone, im new here, and also programming with awk, sed and grep commands on linux. In my text i have many lines with this config: 1 1 4 3 1 1 2 5 2 2 1 1 1 3 1 2 1 3 1 1 1 2 2 2 5 2 4 1 3 2 1 1 4 1 2 1 1 1 3 2 1 1 5 4 1 3 1 1... (3 Replies)
Discussion started by: satir
3 Replies

9. Shell Programming and Scripting

Remove new line starting with a numeric value and append it to the previous line

Hi, i have a file with multiple entries. After some tests with sed i managed to get the file output as follows: lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1, 00,2110597,2094790,0,81,529,75649011,56435363, lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Discussion started by: nms
5 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
MTNOPT(1)							     monotone								 MTNOPT(1)

NAME
mtnopt - generate shell variables from monotone workspace options SYNOPSIS
mtnopt [-s|-c|-v] [-d dir] [-k keys] mtnopt -h DESCRIPTION
mtnopt prints shell variable assignments for each value in the file of monotone workspace options, _MTN/options, in the current directory. For instance, if _MTN/options contained this text: database "/home/user/src/monotone.mtn" branch "net.venge.monotone" keydir "/home/user/.monotone/keys" mtnopt would print: MTN_database="/home/user/src/monotone.mtn"; MTN_branch="net.venge.monotone"; MTN_keydir="/home/user/.monotone/keys"; By default, mtnopt attempts to guess appropriate syntax from the value of the SHELL environment variable. This can be overridden with the -s and -c command-line options. OPTIONS
-s Print variable assignments in sh(1) syntax. -c Print variable assignments in csh(1) syntax. -v Print only the values, with no indication of the corresponding option keys. -d directory Look for _MTN/options in directory, rather than in the current directory. -k keys Print assignments for only those options that match the egrep(1) regular expression keys. -h Print a help message and exit. BUGS
mtnopt only looks in the current directory for the _MTN directory, so it will fail in a subdirectory of a workspace. mtnopt should be aware of the set of possible options, rather than blindly printing whatever is in _MTN/options. The behavior when there is no _MTN/options file to be found is less than helpful. SEE ALSO
mtn(1), egrep(1), sh(1), csh(1) monotone 2011-02-22 MTNOPT(1)
All times are GMT -4. The time now is 11:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy