02-05-2008
using heads and tails...
> cat f1
line 1
line 2
line 3
line 4
line 5
> head -3 f1 | tail -1
line 3
>
in essence, finding the first three lines of a file, then selecting the last line of what I just found.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How can I get and display the last modification time of a file? in scripting or specifically using Batch file
I want this info for me to determine whether an image has been edited or not by using the last modification time and compare it to our stored date of modification.
can somebody help... (5 Replies)
Discussion started by: jaque18
5 Replies
2. UNIX for Dummies Questions & Answers
are there any basic commands that can display lines 99 - 101 of the /etc/passwd file?
I'm thinking use of head and tail, but I forget what numbers to use and where to put /etc/passwd in the command. (2 Replies)
Discussion started by: raidkridley
2 Replies
3. Shell Programming and Scripting
Hi,
I am using below command to display the number of line, but its returning no of lines along with file name.
But i want only no of line in the variable p.
Please help me on this?
p=`wc -l "text file"`
echo "$p" (6 Replies)
Discussion started by: shivanete
6 Replies
4. Shell Programming and Scripting
Hello All,
I am new to this forum. I am currently facing a problem in manipulating files.
I have two files called old-matter and new-matter
# cat old-matter
abc: this, is a, sample, entry
byi: white board, is white in color
rtz: black, board is black
qty: i tried, a lot
asd: no... (1 Reply)
Discussion started by: rahmathulla
1 Replies
5. UNIX for Dummies Questions & Answers
Hi, I'm just wondering how you display a specific set of columns of a specified file in Unix. For example, if you had an AddressBook file that stores the Names, Phone numbers, and Addresses of people the user entered in the following format (the numbers are just to give an idea of what column... (1 Reply)
Discussion started by: logorob
1 Replies
6. Shell Programming and Scripting
Howdy.
I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited?
Example:
You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies
7. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
Display from a csv file, birthdays that occur today. If there are no birthdays today, the next one in the year.
2. Relevant commands, code, scripts, algorithms:
The csv file is ordered from older to younger (ie. the most recent... (8 Replies)
Discussion started by: Adzi
8 Replies
8. Shell Programming and Scripting
Hello
Wondering if anybody may be able to advise on how I can filter the contents of the following file:
<object_name>-<version> <Instance>
GM_GUI_code.fmb-4 1
GM_GUI_code.fmb-5 1
GM_GUI_code.fmx-4 ... (7 Replies)
Discussion started by: Glyn_Mo
7 Replies
9. Shell Programming and Scripting
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Discussion started by: Wynner
3 Replies
10. UNIX for Dummies Questions & Answers
This could be a really dummy question.
I have a log text file.
What unix command to extract line from specific string to another specific string.
Is it something similar to?:
more +/"string" file_name
Thanks (4 Replies)
Discussion started by: aku
4 Replies
fmt(1) User Commands fmt(1)
NAME
fmt - simple text formatters
SYNOPSIS
fmt [-cs] [-w width | -width] [inputfile...]
DESCRIPTION
fmt is a simple text formatter that fills and joins lines to produce output lines of (up to) the number of characters specified in the -w
width option. The default width is 72. fmt concatenates the inputfiles listed as arguments. If none are given, fmt formats text from the
standard input.
Blank lines are preserved in the output, as is the spacing between words. fmt does not fill nor split lines beginning with a `.' (dot), for
compatibility with
nroff(1). Nor does it fill or split a set of contiguous non-blank lines which is determined to be a mail header, the first line of which
must begin with "From".
Indentation is preserved in the output, and input lines with differing indentation are not joined (unless -c is used).
fmt can also be used as an in-line text filter for vi(1). The vi command:
!}fmt
reformats the text between the cursor location and the end of the paragraph.
OPTIONS
-c Crown margin mode. Preserve the indentation of the first two lines within a paragraph, and align the left margin of
each subsequent line with that of the second line. This is useful for tagged paragraphs.
-s Split lines only. Do not join short lines to form longer ones. This prevents sample lines of code, and other such
formatted text, from being unduly combined.
-w width | -width Fill output lines to up to width columns.
OPERANDS
inputfile Input file.
ENVIRONMENT VARIABLES
See environ(5) for a description of the LC_CTYPE environment variable that affects the execution of fmt.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
nroff(1), vi(1), attributes(5), environ(5)
NOTES
The -width option is acceptable for BSD compatibility, but it may go away in future releases.
SunOS 5.10 9 May 1997 fmt(1)