Sponsored Content
Top Forums Shell Programming and Scripting get the fifth line of a text file into a shell script and trim the line to extract a WORD Post 302478727 by Chubler_XL on Wednesday 8th of December 2010 06:18:22 PM
Old 12-08-2010
This will get you the 5th line
Code:
sed -n 5p infile

To check for "string" in 5th line:

Code:
awk 'NR==5&&/string/ {exit 1}' infile || echo "Found it!"

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extract last word on line to new file

Can someone please help me with how to extract the last word on a line to a new file? I have a list of names like: Ms. Nell D. Bullock Mrs. Sherrie M Avent LINDA ANNETTE RUSSELL Mr. Jerome R. Harris Pandora Tyndall I want the new file to look like this: Bullock Avent RUSSELL Harris... (10 Replies)
Discussion started by: michieka
10 Replies

2. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies

3. Shell Programming and Scripting

Help need to cut the first word of a line in text file

Hi All, I would like help with a script which can get rid of the first work of all lines in text file. File 1 The name is Scott. Output : name is Scott ---------- Post updated at 02:38 PM ---------- Previous update was at 02:37 PM ---------- Hi ALL There is typo error in... (3 Replies)
Discussion started by: bubbly
3 Replies

4. UNIX for Dummies Questions & Answers

Script to add text before the first word on a line in a textfile.

How can i make a script to add text before the first word on a line in a textfile : Example: Old line: is my place New line: this is my place Please use and tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks. (3 Replies)
Discussion started by: mjanssen
3 Replies

5. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

6. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

7. Shell Programming and Scripting

HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching

I have a LOG file which looks like this Import started at: Mon Jul 23 02:13:01 EDT 2012 Initialization completed in 2.146 seconds. -------------------------------------------------------------------------------- -- Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies

8. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

9. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

10. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
makedbm(8yp)															      makedbm(8yp)

Name
       makedbm - make a yellow pages dbm file

Syntax
       makedbm [ -i yp_input_file ] [ -o yp_output_name ] [ -d yp_domain_name ] [ -m yp_master_name ] infile outfile
       makedbm [ -u dbmfilename ]

Description
       The command takes the file specified by the argument infile and converts it to a pair of files in format, namely and Each line of the input
       file is converted to a single record.  All characters up to the first tab or space form the key, and the rest of the line is defined as the
       key's  associated data.	If a line ends with a backslash (), the data for that record is continued onto the next line.	It is left for the
       clients of the yellow pages to interpret the number sign (#); does not treat it as a comment character.	The  infile  parameter	can  be  a
       hyphen (-), in which case reads the standard input.

       The  command  is  meant	to  be	used in generating files for the yellow pages service.	The command generates a special entry with the key
       yp_last_modified, which is the date of infile.

Options
       -i     Create a special entry with the key yp_input_file.

       -o     Create a special entry with the key yp_output_name.

       -d     Create a special entry with the key yp_domain_name.

       -m     Create a special entry with the key yp_master_name.  If no master host name is specified, yp_master_name will be set  to	the  local
	      host name.

       -u     Undo a file.  That is, print out a file one entry per line, with a single space separating keys from values.

Examples
       The  following  example shows how a combination of commands can be used to make the yellow pages files and from the file.  The percent sign
       (%) signifies the system prompt.

       % awk 'BEGIN { FS = ":"; OFS = ""; }
	{ print $1, $0 }' /etc/passwd > ptmp
       % makedbm ptmp passwd.byname
       % rm ptmp

       The command creates the file ptmp which is in a form usable by The command uses the ptmp file to create the yellow pages dbm files and  The
       command removes the ptmp file.

See Also
       yppasswd(1yp), dbm(3x), ypmake(8yp)

																      makedbm(8yp)
All times are GMT -4. The time now is 03:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy