Sponsored Content
Top Forums Shell Programming and Scripting A script that read specific fileds from the 7th line in a file Post 302291918 by cfajohnson on Thursday 26th of February 2009 02:52:40 PM
Old 02-26-2009
Quote:
Originally Posted by samura
Dear All,

I need a unix script that will read the 7th line

To read the 7th line from a file:

Code:
{ read; read; read; read; read; read; read line7; } < FILENAME

Or:

Code:
line7=$( sed -n '7{p
q
}' FILENAME  )

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to read specific lines in a file

I have a file with contents as follows Record 1: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 5: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 6:... (5 Replies)
Discussion started by: varshanswamy
5 Replies

2. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

3. Shell Programming and Scripting

How to read specific line of text from a Script and send email notification

Hi ! I am a newbie and never officially wrote a shell script before. The requirement for this script is : 1) Read a file called 'bpm.log' and identify if it has a specific text such as 'this is the text'. Its a static value and that is the only text we need to read. 2) If that... (2 Replies)
Discussion started by: atechcorp
2 Replies

4. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

5. Shell Programming and Scripting

How to read from specific line number in shell script?

I have a text file which is having 30000 lines in it. I have to create a xml file for each 10000 lines until all the lines in the text files are written. Also please help how can i get number of lines in the text file in a shell variable? (19 Replies)
Discussion started by: vel4ever
19 Replies

6. Shell Programming and Scripting

how read specific line in a file and write it in a new text file?

I have list of files in a directory 'dir'. Each file is of type HTML. I need to read each file and get the string which starts with 'http' and write them in a new text file. How can i do this shell scripting? file1.html <head> <url>http://www.google.com</url> </head> file2.html <head>... (6 Replies)
Discussion started by: vel4ever
6 Replies

7. Shell Programming and Scripting

Read file from nth line to specific character

Hi, I want to read the file from nth line (where n is an integer) to until I encounter @ char. Can any one please help me how to do this? Thanks. (3 Replies)
Discussion started by: laalesh
3 Replies

8. Shell Programming and Scripting

How to read particular line in file from specific column?

Hi...friends.... I want to create inventory...information for that I need to read some specific row say 2nd row from 1st 3 column and and write data with particular file used, I have some more column also but I need only 3 column data of first entry after header I attached sample file..those... (12 Replies)
Discussion started by: nex_asp
12 Replies

9. Shell Programming and Scripting

To read specific line from a file

Hi, I have a ldif file like below: version: 1 dn: cn=Test Group,ou=Applications,dc=xyz,dc=com objectClass: groupOfUniqueNames objectClass: top cn: Test Group uniqueMember: uid=abc,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com dn: cn=Test Sub Group,cn=Test... (4 Replies)
Discussion started by: saurau
4 Replies

10. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies
read(n) 						       Tcl Built-In Commands							   read(n)

__________________________________________________________________________________________________________________________________________________

NAME
read - Read from a channel SYNOPSIS
read ?-nonewline? channelId read channelId numChars _________________________________________________________________ DESCRIPTION
In the first form, the read command reads all of the data from channelId up to the end of the file. If the -nonewline switch is specified then the last character of the file is discarded if it is a newline. In the second form, the extra argument specifies how many characters | to read. Exactly that many characters will be read and returned, unless there are fewer than numChars left in the file; in this case all | the remaining characters are returned. If the channel is configured to use a multi-byte encoding, then the number of characters read may | not be the same as the number of bytes read. | If channelId is in nonblocking mode, the command may not read as many characters as requested: once all available input has been read, the | command will return the data that is available rather than blocking for more input. If the channel is configured to use a multi-byte | encoding, then there may actually be some bytes remaining in the internal buffers that do not form a complete character. These bytes will | not be returned until a complete character is available or end-of-file is reached. The -nonewline switch is ignored if the command returns before reaching the end of the file. Read translates end-of-line sequences in the input into newline characters according to the -translation option for the channel. See the fconfigure manual entry for a discussion on ways in which fconfigure will alter input. SEE ALSO
file(n), eof(n), fblocked(n), fconfigure(n) KEYWORDS
blocking, channel, end of line, end of file, nonblocking, read, translation, encoding Tcl 8.1 read(n)
All times are GMT -4. The time now is 04:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy