Sponsored Content
Top Forums Shell Programming and Scripting Print specific line using a variable Post 302830999 by zzavilz on Wednesday 10th of July 2013 03:58:29 AM
Old 07-10-2013
Print specific line using a variable

Hi Everyone,

Is there a way I can print specific lines using sed -n '3,3p' file.dat or awk 'FNR==3' file.dat when using variable?

For example, I have this script (get_line.ksh) that accepts line parameter that a user wanted to print in the file.dat.
Code:
file.dat
one
two
three
four

So if the user ran the script with ./get_line.ksh 4, the script would display four. If the user ran the script with ./get_line.ksh 3, the script would display three and so on...

Thanks,
zzavilz

Last edited by vbe; 07-10-2013 at 05:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print any required line by its line no using awk and its NR variable

how to print any required line by its line no using awk and its NR variable for eg: ------------ 121343 adfdafd 21213sds dafadfe432 adf.adf%adf --------------- requied o/p if give num=3 it print: 21213sds -------------------------------------- (2 Replies)
Discussion started by: RahulJoshi
2 Replies

2. Shell Programming and Scripting

To print a specific line in Shell or awk.

Hi, I want to echo the 15th line from a file named as abc.txt, also i want to echo only the values in that line not the line number. Thanks in advance:) (4 Replies)
Discussion started by: tushar_tus
4 Replies

3. Shell Programming and Scripting

Print a message at specific line on prompt

Hi Friends, I am using HP-UNIX(ksh). I want to print a message at specific line on the prompt screen. For Example: for num in 1 10 3 145 do echo $num // need to print this on the same line for each number sleep 2 done Actual Output: ========== 1 10 3 145 Expected Output:... (5 Replies)
Discussion started by: Niroj
5 Replies

4. Shell Programming and Scripting

Search in specific position and print the whole line

I have two files abc.dat and sant.dat (Big file 60k rows) for every line's 1,4 of abc.dat need to seach if this is present on 28,4 of sant.dat every line. if its present the output needs to go to bde.dat Example: contents abc.dat aaaa bbbb cccc dddd contents sant.dat this is... (4 Replies)
Discussion started by: ssantoshss
4 Replies

5. Programming

Print specific pattern line in c++

Input file: @HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC +HWI-BRUNOP1_header_1 TNTTJTTTETceJSP__VRJea`_NfcefbWe Desired output file: >HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC >HWI-BRUNOP1_header_2... (10 Replies)
Discussion started by: cpp_beginner
10 Replies

6. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

7. Shell Programming and Scripting

want to print the file content from the specific line

Hi All, I would like to print the content from the specific line of a file . For example... i have file abc.txt which has 100 lines of code ,from this file i would like to print the content from 20,19,18th line......like that Regards Srikanth (4 Replies)
Discussion started by: srikanthg
4 Replies

8. Shell Programming and Scripting

Help to just print out specific line from an input file

Hi, I have a file which contains 2,500,500,432 lines. Can I know what command I should type in order just print out particular line from the input file? eg. I just wanna to see what is the contents at line 522,484,612. Thanks for advice. (3 Replies)
Discussion started by: perl_beginner
3 Replies

9. Shell Programming and Scripting

Print String Every Specific Line

Dear All, I have input file like this, 001 059 079 996 758 079 069 059 079 ... ... Desired output: AA 001 BB 059 (4 Replies)
Discussion started by: attila
4 Replies

10. Shell Programming and Scripting

Help with print out line that have different record in specific column

Input file 1: - 7367 8198 - 8225 9383 + 9570 10353 Input file 2: - 2917 3667 - 3851 4250 + 4517 6302 + 6302 6740 + 6768 7524 + 7648 8170 + 8272 8896 + 8908 9915 - 10010 ... (18 Replies)
Discussion started by: perl_beginner
18 Replies
geom(1) 																   geom(1)

NAME
geom - analyzes a molecular geometry input in Cartesian coordinates. DESCRIPTION
The program geom reads a set of Cartesian coordinates and determines from them the bond distances (Bohr and angstrom), bond angles, tor- sional angles, out-of-plane angles (optional), moments of inertia, and rotational constants. FILES REQUIRED
input.dat - Input file and one of the following: geom.dat - geometry file file11.dat - PSI-format geometry/gradient file FILES GENERATED
geom.out - file containing the analysis INPUT OPTIONS
The geom program has the following options: -h Print help information (these options). -aces [filename] Read the input in an ACES output format, with each line consisting of atomic symbol, atomic number, and Cartesian coordinates (in Bohr). The optional argument is the name of the geometry input file, which defaults to geom.dat. -qchem [filename] Read the input in an QCHEM output format, with each line consisting of the atom number, the atomic symbol, and Cartesian coordinates (in Angstroms). The optional argument is the name of the geometry input file, which defaults to geom.dat. -xyz [filename] Read the input in an XYZ output format. The first line contains the number of atoms and the second line is a comment line. Subse- quent lines each contain the atomic symbol and Cartesian X Y and Z coordinates (in Angstroms). The optional argument is the name of the geometry input file, which defaults to geom.dat. -oop Print out-of-plane angles, where the angle a-b-c-d is defined as the angle formed by the vector a-d and the plane defined by atoms b, c, and d. DO_OOP = boolean Same as command-line switch -oop described above. ISOTOPES = matrix of reals/strings Used to specify masses to be used in the calculation of the center of mass and rotational constants. One array is provided for each isotopomer to be calculated. The arrays can mix floating point numbers with strings which designate isotopes. If this array is not given and file11.dat is present, then the masses will be obtained by converting the atomic numbers in file11. If masses are not given by ISOTOPES or by file11, then no mass-related quantities will be calculated. -g [filename] Read Cartesian coordinates from a file other than file11.dat. If a filename is not given, the default is geom.dat. The alternative file is assumed to be in a format similar to that of PSI's geom.dat. Since such files do not contain atomic numbers, the moments of inertia and rotational constants are not calculated if this option is used. READ_GEOM = boolean This option in input.dat tells geom to read the geometry from geom.dat in the PSI geom.dat format. -a Print parameters for all pair distances. PRINT_ALL_DIST = boolean Same as -a flag described above. -d distance Only print parameters involving pairs of atoms which are less than distance bohr apart (default value is 4.0 bohr). PRINT_DISTANCE = value Same as -d flag described above. -angstrom The input coordinates are in angstroms, not bohr. ANGSTROM = boolean If TRUE, the input coordinates are in angstroms instead of bohr. The default is FALSE. The following example is for calculating the geometrical information for water with several different isotopes. The geometry is read from geom.dat rather than from file11.dat. geom: ( read_geom = true isotopes = ( (O H H) (O D D) (O18 1.007825 1.007825) ) ) 5 June, 1998 geom(1)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy