The previous solutions are NICER, but this uses some commands in unusual ways, so I thought it would be interesting (and educational) to see them used in this manner.
Explained:
I put a line number with each of your lines
grep for the requested text
determine its line number
start my display at that line number
and continue for ten lines
hello,
I go text file like this
E:/DDD/Dyndede/wwww
E:/DDD/sss.com/ffffg/fff
E:/DDD/vvvvvv/dd
E:/DDD/sss.com/bbbbbb
E:/DDD/sss.com/nnnn/xxI want to print
/alpha.jpg at the end of every lines like that
E:/DDD/Dyndede/wwww/alpha.jpg
E:/DDD/sss.com/ffffg/fff/alpha.jpg... (8 Replies)
Hi ,
I have a huge file like this
=245 this is testing
=035 abc123
=245 this is testing1
=035 abc124
=245 this is testing2
=035 abc125
=035 abc126
=245 this is testing3
here i have to pull out those lines having two =035 instead of alternative 035 and 245 i.e extract... (18 Replies)
Hi guys,
I usualy am able to google awk stuff but I can't find it so far and there are so many awking gurus here that I will give it a shot.
I want to print $1;$3;"$5 up to the $NF". In other words, I can have 1000 colums, but need to have $5 up to the end.
I started with the idea of... (2 Replies)
Hi
I have requirement to find nth occurrence in a file and capture data from with in lines (between lines)
Data in File.
<QUOTE>
<SESSION>
<ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/>
<ATTRIBUTE NAME='Service Name' VALUE='None'/>
</SESSION>
<SESSION>
<ATTRIBUTE... (6 Replies)
Hi,
I have a file with contents
test id text day
test sah dh dhs
yeay fg jsh jsjk
my need:
I give a string as a input, it check the file and display the lines with the given string
e.g
input : test
output:
test id text day
test sah dh dhs (1 Reply)
I have a large dataset with following structure;
C 0001 Carbon
D SAR001 methane
D SAR002 ethane
D SAR003 propane
D SAR004 butane
D SAR005 pentane
C 0002 Hydrogen
C 0003 Nitrogen
C 0004 Oxygen
D SAR011 ozone
D SAR012 super oxide
C 0005 Sulphur
D SAR013... (3 Replies)
e.g.
File name: File.txt
cat File.txt
Result:
#INBOUND_QUEUE=FAQ1
INBOUND_QUEUE=FAQ2
I want to get the value for one which is not commented out.
Thanks, (3 Replies)
I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with:
wc -l *|sort
15263 Image.txt
16401 reference.txt
40459 richtexteditor.txt
How can I also print the number of unique lines in each file?
15263 1401 Image.txt
16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
LEARN ABOUT SUNOS
head
head(1) User Commands head(1)NAME
head - display first few lines of files
SYNOPSIS
head [-number | -n number] [filename...]
DESCRIPTION
The head utility copies the first number of lines of each filename to the standard output. If no filename is given, head copies lines from
the standard input. The default value of number is 10 lines.
When more than one file is specified, the start of each file will look like:
==> filename <==
Thus, a common way to display a set of short files, identifying each one, is:
example% head -9999 filename1 filename2 ...
OPTIONS
The following options are supported:
-n number The first number lines of each input file will be copied to standard output. The number option-argument must be a positive
decimal integer.
-number The number argument is a positive decimal integer with the same effect as the -n number option.
If no options are specified, head will act as if -n 10had been specified.
OPERANDS
The following operand is supported:
file A path name of an input file. If no file operands are specified, the standard input will be used.
USAGE
See largefile(5) for the description of the behavior of head when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
EXAMPLES
Example 1: Writing the first ten lines of all files
To write the first ten lines of all files (except those with a leading period) in the directory:
example% head *
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of head: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO cat(1), more(1), pg(1), tail(1), attributes(5), environ(5), largefile(5), standards(5)SunOS 5.10 1 Feb 1995 head(1)