08-29-2016
With almost 200 posts to your credit, we would hope that you would have learned enough from the suggestions you've seen posted here that you would have a good start at getting the results you want. What have you tried to solve this problem on your own?
What operating system and shell (including version number) are you using?
With five lines of text (two of which are empty lines) in var1 and three lines of text in var2, what output are you hoping to produce?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to parse iostat output for io issues..
I want to print all lines including second occurance of 'extended' till EOF(end of file). Can we do that using awk or sed one liners or do we need a script for it? (1 Reply)
Discussion started by: kchinnam
1 Replies
2. UNIX for Dummies Questions & Answers
Ok so I can use awk to match a pattern and print the whole line with print $0. Is there any way to just tell awk to print every line of output when the pattern matches?
I'm having it wait for the word error and then print that entire line. But what I actually need to see is all the following... (9 Replies)
Discussion started by: MrEddy
9 Replies
3. Shell Programming and Scripting
I am using Solaris, I want to print
3 lines before pattern match
pattern
5 lines after pattern match
Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks ..
Input File a.txt:
=================
1
2
3
abcd
4
5
6
7
8 (7 Replies)
Discussion started by: manuswami
7 Replies
4. Shell Programming and Scripting
Hi all
I have a text file with the following format:
id col1 col2 col3 col4 col5 col6 col7 ...
row1 0 0 0 0 0 0 0
row2 0 0 0 0 0 0 0
row3 0 0 0 0 0 0.2 0
row4 0 0 0 0 0 0 0
row5 0 0 0 0 0 0 0
row6 0 0 0 0.1 0 0 0
row7 0 0 0 0 0 0 0
row8 0 0 0 0 0 0 0
row9 0 0 0 0 0 0 0
...
The file... (2 Replies)
Discussion started by: gautig
2 Replies
5. Shell Programming and Scripting
Hi, I have this file.
close
block3c
block3b
block3a
open
close
block2b
block2a
open
close
block1a
open
and I need :
open
block3a
block3b
block3c
close (1 Reply)
Discussion started by: lasserfox
1 Replies
6. Shell Programming and Scripting
I need to print the lines that do not match a pattern. I tried using grep -v and sed -n '/pattern/!p', but both of them are not working as I am passing the pattern as variable and it can be null some times.
Example
........ abcd......
.........abcd......
.........abcd......... (4 Replies)
Discussion started by: sunny1234
4 Replies
7. UNIX for Dummies Questions & Answers
I am getting the varible value from a grep command as:
var=$(grep "Group" File1.txt | sed 's/Group Name*//g;s/,//g;s/://g;s/-//g')
which leaves me the value of $var=xyz.
now i want to append $var value in the begining of all the lines present in the file. Can u please suggest?
Input file:
1... (10 Replies)
Discussion started by: rade777
10 Replies
8. UNIX for Dummies Questions & Answers
URGENT HELP IS NEEDED!!
I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but
- Currently, script is not printing lines to File3.txt in order.
- Also the matching lines are not moving out of File1.txt
... (1 Reply)
Discussion started by: High-T
1 Replies
9. Shell Programming and Scripting
Hello,
I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me.
Sample file :
name id
AAA 123
AAB 124
AAC 125... (4 Replies)
Discussion started by: Shenbaga.d
4 Replies
10. Shell Programming and Scripting
I have input file as below I need to check for a pattern and if it is there in file then I need to print all the lines below BEGIN and END keyword. Could you please help me how to get this in AIX using sed or awk.
Input file:
ABC
******** BEGIN *****
My name is Amit.
I am learning unix.... (8 Replies)
Discussion started by: Amit Joshi
8 Replies
nl(1) General Commands Manual nl(1)
NAME
nl - line numbering filter
SYNOPSIS
type] type] type] start#] incr] sep] width] format] num] delim] [file]
DESCRIPTION
reads lines from the named file or the standard input if no file is named and reproduces the lines on the standard output. Lines are num-
bered on the left in accordance with the command options in effect.
views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page consists of
a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently available for
header, body, and footer (e.g., no numbering of header and footer lines while numbering blank lines only in the body).
The start of logical page sections are signaled by input lines containing nothing but the following delimiter character(s):
|
Line contents | Start of
--------------+----------
::: | header
:: | body
: | footer
Unless told otherwise, assumes the text being read is in a single logical page body.
Command options can appear in any order and can be intermingled with an optional file name. Only one file can be named. recognizes the
following options:
Specifies which logical page body lines are to be numbered.
Recognized types and their meanings are:
number all lines;
number lines with printable text only;
no line numbering;
number only lines that contain the regular expression
specified in string. Basic Regular Expression syntax is supported (see regexp(5)).
The default type for logical page body is (text lines numbered).
Same as except for header. Default type for logical page header is (no lines numbered).
Same as except for footer. Default for logical page footer is (no lines numbered).
Do not restart numbering at logical page delimiters.
start# is the initial value used to number logical page lines. Default is
incr is the increment value used to number logical page lines. Default is
sep is the character or characters used in separating the line number and the corresponding text line. Default sep is a
tab.
width is the number of character columns to be used for the line number. Default width is
format is the line numbering format. Recognized values are:
left justified, leading zeroes
suppressed;
right justified,
leading zeroes suppressed;
right justified, leading zeroes kept.
Default format is (right justified).
num is the number of consecutive blank lines to be treated and numbered as a single line. For example, results in every
third adjacent blank line being numbered if the appropriate and/or option is set. Default is
The delimiter characters specifying the start of a logical page
section can be changed from the default characters to two user-specified characters. If only one character is entered,
the second character remains the default character No space should appear between the and the delimiter characters, how-
ever, this restriction is not there for (see standards(5)) compliant To define a backslash as the delimiter, use two
backslashes.
EXTERNAL INFLUENCES
For information about the UNIX Standard environment, see standards(5).
Environment Variables
determines the collating sequence used in evaluating regular expressions.
determines the characters matched by character class expressions in regular expressions.
If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of
If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See
environ(5).
International Code Set Support
Single-byte character code sets are supported.
EXAMPLES
Number starting at line number 10, using an increment of ten. The logical page delimiters are and
SEE ALSO
pr(1), environ(5), lang(5), regexp(5), standards(5).
STANDARDS CONFORMANCE
nl(1)