Sponsored Content
Top Forums Shell Programming and Scripting Move a line containg "char" above line containing "xchar" Post 302938736 by vgersh99 on Wednesday 18th of March 2015 04:10:01 PM
Old 03-18-2015
awk -f rex.awk myFile, where rex.awk is:

Code:
BEGIN {
  pat2move="TYPE            = Router"
  patBelow="[[Cisco]]"
}
$0 ~ pat2move {next}
$0 ~ patBelow { $0 = $0 ORS pat2move}
1

Disclaimer: with some basic assumptions - YMMV

Last edited by vgersh99; 03-18-2015 at 05:19 PM.. Reason: more succinct
This User Gave Thanks to vgersh99 For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

How to remove "New line characters" and "spaces" at a time

Dear friends, following is the output of a script from which I want to remove spaces and new-line characters. Example:- Line1 abcdefghijklmnopqrstuvwxyz Line2 mnopqrstuvwxyzabcdefghijkl Line3 opqrstuvwxyzabcdefdefg Here in above example, at every starting line there is a “tab” &... (4 Replies)
Discussion started by: anushree.a
4 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

AWK for multiple line records RS="^" FS="#"

I have to pull multiple line records with ^ as the record separator(RS)... # should be my field separator (FS)... Sample record is: ^-60#ORA-00060: deadlock detected while waiting for resource ORA-00001: unique constraint (SARADM.TCKNUM_PK) violated#PROC:AVAILABLE_FOR_GETNXTTIC#02/27/2012... (7 Replies)
Discussion started by: Vidhyaprakash
7 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

Find "*.c" and "Makefile" and then delete them with one line

find "*.c" and "Makefile" and then delete them with one line (3 Replies)
Discussion started by: yanglei_fage
3 Replies

7. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

8. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
VBINDIFF(1)						       Christopher J. Madsen						       VBINDIFF(1)

NAME
vbindiff - hexadecimal file display and comparison SYNOPSIS
vbindiff file1 [ file2 ] DESCRIPTION
Visual Binary Diff (VBinDiff) displays files in hexadecimal and ASCII (or EBCDIC). It can also display two files at once, and highlight the differences between them. Unlike diff, it works well with large files (up to 4 GB). Viewing files Movement Keys ------------- Up Move one line (16 bytes) towards the beginning of the file Down Move one line (16 bytes) towards the end of the file Left Move one byte towards the beginning of the file Right Move one byte towards the end of the file PageUp Move one page towards the beginning of the file PageDn Move one page towards the end of the file Home Move to the beginning of the file End Move to the end of the (shorter) file F Search for a string or byte sequence G Move to a specified file position When displaying two files, both files move together. If bytes have been added or removed in one of the files, you can adjust the compari- son by moving just one of the files. To move only the top file, press "T". To move only the bottom file, press "B". To return to moving both files, press the same key again. (The window at the bottom of the screen will indicate when you are moving only one file.) Other Keys ---------- Enter Move to the next difference between the files Space (same as Enter) C Toggle between ASCII and EBCDIC display E Edit currently displayed section of file Esc Exit VBinDiff Q Exit VBinDiff The "Enter" key will advance to the next difference between the files (after those already displayed on the screen). If there are no more differences, it moves to the end. Line editor The line editor is used to enter search strings and file positions. It uses the basic Emacs-style editing keys. Keys ----------------- Ctrl-B, Left Move the cursor one character left Ctrl-F, Right Move the cursor one character right Ctrl-A, Home Move to the beginning of the line Ctrl-E, End Move to the end of the line Ctrl-P, Up Move up in input history Ctrl-N, Down Move down in input history Ctrl-H, Backspace Delete the character to the left Ctrl-D, Delete Delete the character under the cursor Ctrl-K Delete from cursor to end of line Insert Toggle between insert & overstrike mode Enter Finished entering text Esc Abort the operation Editing files You can press "E" to edit the current file. When displaying two files, this edits the one in the top window, unless you are in "move bot- tom" mode. When editing, you can move the cursor around with the arrow keys. Use TAB to switch between entering hexadecimal or ASCII (or EBCDIC) characters. Press the Esc key when you are done. You will be given the choice to save or discard your changes then. If you are displaying two files, you can use the Enter key to copy a byte from the other file into the one you are editing. You cannot scroll through the file while editing, although you can save your changes and then move to a different part of the file. Also, you cannot insert or delete bytes, only change them. OPTIONS
-L, --license Display license information for vbindiff -V, --version Display the version number --help Display help information BUGS
Does not work properly with files over 4 gigabytes. It should be able to view the first 4 gigabytes ok, but the display only has room for 8 hex digits of file position, and the Goto box is also limited to 8 digits. LICENSE
VBinDiff is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VBinDiff is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VBinDiff (see the file COPYING); if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. AUTHOR
Christopher J. Madsen <vbindiff .at. cjmweb.net> <http://www.cjmweb.net/vbindiff/> VBinDiff 3.0_beta3 2008-06-25 VBINDIFF(1)
All times are GMT -4. The time now is 10:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy