Help to just print out specific line from an input file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help to just print out specific line from an input file
# 1  
Old 11-25-2012
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.
# 2  
Old 11-25-2012
Code:
sed -n '522484612' input_file

Good luck.
# 3  
Old 11-25-2012
Code:
sed -n '522484612{;p;q;}' file

---------- Post updated at 04:28 AM ---------- Previous update was at 04:24 AM ----------

Quote:
Originally Posted by patrick87
Code:
sed -n '522484612' input_file

Good luck.
That's not a valid sed script. If I got your intention right, it ought to have been
Code:
sed -n '522484612p' input_file

But, even then it's a useless command. sed will read the whole file which is not at all required.
This User Gave Thanks to elixir_sinari For This Post:
# 4  
Old 11-25-2012
With awk
Code:
 awk 'NR==522484612 {print;exit}' file

This User Gave Thanks to Jotne For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to verify each line in input for specific pattern

In the bash below the out put of a process is written to input. What I am trying to do is read each line in the input and verify/check it for specific text (there are always 6 lines for each file and the specific text for each line is in the description). There will always be 6 lines in each... (5 Replies)
Discussion started by: cmccabe
5 Replies

2. Shell Programming and Scripting

awk to combine all matching fields in input but only print line with largest value in specific field

In the below I am trying to use awk to match all the $13 values in input, which is tab-delimited, that are in $1 of gene which is just a single column of text. However only the line with the greatest $9 value in input needs to be printed. So in the example below all the MECP2 and LTBP1... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Perl to identify specific runs in input and print only lines identified

In the perl one-liner below I am identifying the runs of 6a or 6A in each line starting with >. The code seems close but it prints each > line no matter if it has 6a or 6A in it. Only the line with the 6a or 6A needs to be printed. So using the input file, only the >hg19_refGene_NM_001918_3... (10 Replies)
Discussion started by: cmccabe
10 Replies

4. Shell Programming and Scripting

awk to print specific line in file based on criteria

In the file below I am trying to extract a specific instance of path, if the adjacent plugin": "/rundb/api/v1/plugin/49/. Thank you :). file "path": "/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52", "plugin": "/rundb/api/v1/plugin/49/",... (8 Replies)
Discussion started by: cmccabe
8 Replies

5. Shell Programming and Scripting

Input file needs to match a column and print the entire line

I have a file with class c IP addresses that I need to match to a column and print the matching lines of another file. I started playing with grep -if file01.out file02.out but I am stuck as to how to match it to a column and print the matching lines; cat file01.out 10.150.140... (5 Replies)
Discussion started by: lewk
5 Replies

6. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 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

Passing parameter in sed or awk commands to print for the specific line in a file

Hi, I am trying to print a specific line in a file through sed or awk. The line number will be passed as a parameter from the previous step. My code looks as below. TEMP3=`sed -n '$TEMP2p' $FILEPATH/Log.txt` $TEMP2, I am getting from the previous step which is a numerical value(eg:3). ... (2 Replies)
Discussion started by: satyasrin82
2 Replies

9. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

10. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies
Login or Register to Ask a Question