Sponsored Content
Full Discussion: Sorting indented text files
Top Forums Shell Programming and Scripting Sorting indented text files Post 302921001 by RudiC on Tuesday 14th of October 2014 06:31:31 AM
Old 10-14-2014
This will work on your certainly simplified sample file. Not sure it will on real data...:
Code:
awk '/!/{next} !/^ +/ {S=$0; print; next} {$0=S " " $0} 1' file | sort | awk 'NF>2 {$1=$2=""}1'
command a
command b
command c
command d
interface a
  podcommand a
  podcommand b
interface b
  podcommand a
  podcommand b

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting rules on a text section

Hi all My text file looks like this: start doc ... (certain number of records) REC3|Emma|info| REC3|Lukas|info| REC3|Arthur|info| ... (certain number of records) end doc start doc ... (certain number of records)... (4 Replies)
Discussion started by: Indalecio
4 Replies

2. Shell Programming and Scripting

awk error in sorting text file

Hi Having a file as below file.txt error Server Network Name Dept Date Time =========================================================================================================================== 0 ServerA LAN1 AAA IT01 04/30/2008 09:16:26 0 ... (3 Replies)
Discussion started by: karthikn7974
3 Replies

3. UNIX for Dummies Questions & Answers

sorting files with find command before sending to text file

i need help with my script.... i am suppose to grab files within a certain date range now i have done that already using the touch and find command (found them in other threads) touch -d "$date_start" ./tmp1 touch -d "$date_end" ./tmp2 find "$data_location" -maxdepth 1 -newer ./tmp1 !... (6 Replies)
Discussion started by: deking
6 Replies

4. Shell Programming and Scripting

Sorting a text file

In unix how to sort in reverse order based on second field in a text file. $ cat data1 David:501 Albie:503 Shaun:502 The expected output: Albie:503 Shaun:502 David:501 Please help :) (4 Replies)
Discussion started by: jon2ryhme
4 Replies

5. Shell Programming and Scripting

Group on the basis of common text in the square bracket and sorting

File A 99 >ac >ss >juk 70 >acb >defa 90 >ca 100 >aa >abc >bca 85 >cde 81 >ghi >ghij 87 >def >fgh <ijk 89 >fck >ghij >kill >aa The given output shud be 100 >aa >abc >bca 87 >def >fgh <ijk 89 >fck >ghij >kill >aa (2 Replies)
Discussion started by: cdfd123
2 Replies

6. Shell Programming and Scripting

i need help in sorting two files

i have file a 123 234 456 567 678 and file b 123|xxx|hhh|ppp or zzz 234|rrr|ttt|xxx 432|ttt|mmm|nnn 678|cft|byt|mop i want to compare file a to file b such that when each of the lines in file a can be found in file b column1 and also xxx or hhh or ppp or zzz can be... (12 Replies)
Discussion started by: blackzinga80
12 Replies

7. Shell Programming and Scripting

sorting based on a specified column in a text file

I have a tab delimited file with 5 columns 79 A B 20.2340 6.1488 8.5086 1.3838 87 A B 0.1310 0.0382 0.0054 0.1413 88 A B 46.1651 99.0000 21.8107 0.2203 89 A B 0.1400 0.1132 0.0151 0.1334 114 A B 0.1088 0.0522 0.0057 0.1083 115 A B... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

8. UNIX Desktop Questions & Answers

Problem in sorting a text file

Hi; I have a text file like this: 1 10 11 2 3 4 M X Y When I sort it numerically using sort -n, it looks like this: Y X M 1 2 3 4 10 (3 Replies)
Discussion started by: a_bahreini
3 Replies

9. Shell Programming and Scripting

Complex data sorting in excel files or text files

Dear all, I have a complex data file shown below,,,,, A_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919 C_ABCD_13208 0 0 4.16735 141044 902449 1293900 168919 A_ABCDEF715 52410.9 18598.2 10611 10754.7 122535 252426 36631.4 C_DBCDI_1353 0... (19 Replies)
Discussion started by: AAWT
19 Replies

10. Shell Programming and Scripting

Sorting a text file with respect to Function/Keyword

Hello Experts, I am truly a beginner in shell and perl . Need an urgent help with sorting a file. please help. wouldn't mind whether in perl or shell script. Here are the details. ------------------------------------------------------ Input Text file EX:... (9 Replies)
Discussion started by: pradyumnajpn10
9 Replies
GROFF_MAN(7)						 Miscellaneous Information Manual					      GROFF_MAN(7)

NAME
groff_man - groff `man' macros to support generation of man pages SYNOPSIS
groff -man [ options... ] [ files... ] groff -m man [ options... ] [ files... ] DESCRIPTION
The man macros used to generate man pages with groff were written by James Clark. This document provides a brief summary of the use of each macro in that package. OPTIONS
The man macros understand the following command line options (which define various registers). -rLL=line-length Set line length. If this option is not given, the line length defaults to 78n in nroff mode and 6.5i in troff mode. -rLT=title-length Set title length. If this option is not given, the title length defaults to 78n in nroff mode and 6.5i in troff mode. -rcR=1 This option (the default if in nroff mode) will create a single, very long page instead of multiple pages. Say -rcR=0 to disable it. -rC1 If more than one manual page is given on the command line, number the pages continuously, rather than starting each at 1. -rD1 Double-sided printing. Footers for even and odd pages are formatted differently. -rPnnn Enumeration of pages will start with nnn rather than with 1. -rSxx Base document font size is xx points (xx can be 10, 11, or 12) rather than 10 points. -rXnnn After page nnn, number pages as nnna, nnnb, nnnc, etc. For example, the option `-rX2' will produce the following page numbers: 1, 2, 2a, 2b, 2c, etc. USAGE
This section describes the available macros for manual pages. For further customization, put additional macros and requests into the file man.local which will be loaded immediately after the man package. .TH title section [extra1] [extra2] [extra3] Sets the title of the man page to title and the section to section, which must take on a value between 1 and 8. The value section may also have a string appended, e.g. `.pm', to indicate a specific subsection of the man pages. Both title and section are posi- tioned at the left and right in the header line (with section in parentheses immediately appended to title. extra1 will be posi- tioned in the middle of the footer line. extra2 will be positioned at the left in the footer line (resp. at the left on even pages and at the right on odd pages if double-sided printing is active). extra3 is centered in the header line. For HTML output, headers and footers are completely supressed. Additionally, this macro starts a new page; the new line number is 1 again (except if the `-rC1' option is given on the command line) -- this feature is intended only for formatting multiple man pages; a single man page should contain exactly one TH macro at the beginning of the file. .SH [text for a heading] Sets up an unnumbered section heading sticking out to the left. Prints out all the text following SH up to the end of the line (resp. the text in the next input line if there is no argument to SH) in bold face, one size larger than the base document size. Additionally, the left margin for the following text is reset to its default value. .SS [text for a heading] Sets up an secondary, unnumbered section heading. Prints out all the text following SS up to the end of the line (resp. the text in the next input line if there is no argument to SS) in bold face, at the same size as the base document size. Additionally, the left margin for the following text is reset to its default value. .TP [nnn] Sets up an indented paragraph with label. The indentation is set to nnn if that argument is supplied (the default unit is `n' if omitted), otherwise it is set to the default indentation value. The first input line of text following this macro is interpreted as a string to be printed flush-left, as it is appropriate for a label. It is not interpreted as part of a paragraph, so there is no attempt to fill the first line with text from the following input lines. Nevertheless, if the label is not as wide as the indenta- tion, then the paragraph starts at the same line (but indented), continuing on the following lines. If the label is wider than the indentation, then the descriptive part of the paragraph begins on the line following the label, entirely indented. Note that nei- ther font shape nor font size of the label is set to a default value; on the other hand, the rest of the text will have default font settings. The TP macro is the macro used for the explanations you are just reading. .LP .PP .P These macros are mutual aliases. Any of them causes a line break at the current position, followed by a vertical space downwards by the amount specified by the PD macro. The font size and shape are reset to the default value (10pt resp. Roman). Finally, the cur- rent left margin is restored. .IP [designator] [nnn] Sets up an indented paragraph, using designator as a tag to mark its beginning. The indentation is set to nnn if that argument is supplied (default unit is `n'), otherwise the default indentation value is used. Font size and face of the paragraph (but not the designator) are reset to its default values. To start an indented paragraph with a particular indentation but without a designator, use `""' (two doublequotes) as the second argument. For example, the following paragraphs were all set up with bullets as the designator, using `.IP (bu 4': o IP is one of the three macros used in the man package to format lists. o HP is another. This macro produces a paragraph with a left hanging indentation. o TP is another. This macro produces an unindented label followed by an indented paragraph. .HP [nnn] Sets up a paragraph with hanging left indentation. The indentation is set to nnn if that argument is supplied (default unit is `n'), otherwise the default indentation value is used. Font size and face are reset to its default values. The following paragraph illustrates the effect of this macro with hanging indentation set to 4: This is a paragraph following an invocation of the HP macro. As you can see, it produces a paragraph where all lines but the first are indented. .RS [nnn] This macro moves the left margin to the right by the value nnn if specified (default unit is `n'); otherwise the default indentation value is used. Calls to the RS macro can be nested. .RE [nnn] This macro moves the left margin back to level nnn; if no argument is given, it moves one level back. The first level (i.e., no call to RS yet) has number 1, and each call to RS increases the level by 1. To summarize, the following macros cause a line break with the insertion of vertical space (which amount can be changed with the PD macro): SH, SS, TP, LP (PP, P), IP, and HP. The macros RS and RE also cause a break but no insertion of vertical space. Finally, the macros SH, SS, LP (PP, P), and RS reset the indentation to its default value. MACROS TO SET FONTS
The standard font is Roman; the default text size is 10 point. .SM [text] Causes the text on the same line or the text on the next input line to appear in a font that is one point size smaller than the default font. .SB [text] Causes the text on the same line or the text on the next input line to appear in boldface font, one point size smaller than the default font. .BI text Causes text on the same line to appear alternately in bold face and italic. The text must be on the same line as the macro call. Thus .BI this "word and" that would cause `this' and `that' to appear in bold face, while `word and' appears in italics. .IB text Causes text to appear alternately in italic and bold face. The text must be on the same line as the macro call. .RI text Causes text on the same line to appear alternately in roman and italic. The text must be on the same line as the macro call. .IR text Causes text on the same line to appear alternately in italic and roman. The text must be on the same line as the macro call. .BR text Causes text on the same line to appear alternately in bold face and roman. The text must be on the same line as the macro call. .RB text Causes text on the same line to appear alternately in roman and bold face. The text must be on the same line as the macro call. .B [text] Causes text to appear in bold face. If no text is present on the line where the macro is called, then the text of the next input line appears in bold face. .I [text] Causes text to appear in italic. If no text is present on the line where the macro is called, then the text of the next input line appears in italic. MISCELLANEOUS
The default indentation is 7.2n for all output devices except for grohtml which ignores indentation. .DT Sets tabs every 0.5 inches. Since this macro is always called during a TH request, it makes sense to call it only if the tab posi- tions have been changed. .PD [nnn] Adjusts the empty space before a new paragraph (resp. section). The optional argument gives the amount of space (default units are `v'); without parameter, the value is reset to its default value (1 line for tty devices, 0.4v otherwise). This affects the macros SH, SS, TP, LP (resp. PP and P), IP, and HP. The following strings are defined: *S Switch back to the default font size. *R The `registered' sign. *(Tm The `trademark' sign. *(lq *(rq Left and right quote. This is equal to `(lq' and `(rq', respectively. If a preprocessor like tbl or eqn is needed, it has become usage to make the first line of the man page look like this: ." word Note the single space character after the double quote. word consists of letters for the needed preprocessors: `e' for eqn, `r' for refer, and `t' for tbl. Modern implementations of the man program read this first line and automatically call the right preprocessor(s). FILES
man.tmac an.tmac These are wrapper files to call andoc.tmac. andoc.tmac This file checks whether the man macros or the mdoc package should be used. an-old.tmac All man macros are contained in this file. man.local Local changes and customizations should be put into this file. SEE ALSO
Since the man macros consist of groups of groff requests, one can, in principle, supplement the functionality of the man macros with indi- vidual groff requests where necessary. A complete list of these requests is available on the WWW at http://www.cs.pdx.edu/~trent/gnu/groff/groff_toc.html tbl(1), eqn(1), refer(1), man(1) AUTHOR
This manual page was originally written for the Debian GNU/Linux system by Susan G. Kleinmann <sgk@debian.org>, corrected and updated by Werner Lemberg <wl@gnu.org>, and is now part of the GNU troff distribution. Groff Version 1.18.1 05 September 2002 GROFF_MAN(7)
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy