Read any lines of text from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read any lines of text from file
# 1  
Old 10-19-2009
Read any lines of text from file

Witam wszystkich ,

Jest to moj pierwszy post i już prośba ale gdybym potrafił zaradzić problemowi to nie zawracałbym nikomu głowy .

mianowicie :

Mam jakis 'plik' w ktorym są osadzone pojedyncze i zmienne słowa po jednym w lini czyli :

test1
tekttw
resst
.... itd.

Moje pytanie brzmi :

- jak mam odczytać z tego pliku konkretną linie i przekazać wyjście do innego pliku ? Czy jest jakieś polecenie które to umożliwia w prosty sposób ?


Pozdrawiam

Last edited by zaxxon; 10-20-2009 at 03:48 AM.. Reason: Changed topic
# 2  
Old 10-19-2009
Bitte ne pas parlare po Polsku pero in English graag...
# 3  
Old 10-19-2009
sory ,

Hi all,

This is my first post and I asked if I could but it did not address this problem would bother anyone's head.

namely:

I have a 'file' in which they are embedded single and variable words in one line that is:


test1
tekttw
resst
.... itd.

My question is:

- As I read from this file and specific line of the output to another file? Is there a command that enables the easy way?
# 4  
Old 10-19-2009
Do you mean like this?
Code:
grep tekttw file > found.txt

# 5  
Old 10-19-2009
not the case, has further explained:

I am doing a script that queries the ports of my server and saves results to a file in the form:

=== file wyn1.log ===
open
closed
closed
open
open
================

the first line is the first port of argument given in the script for the second line is the second port of script given as an argument ........

I need to read any line.

Code:
nmap -n -r -p$port $domena | awk 'BEGIN {RS=" "} /closed/ || /open/ ' >>  wyn1.log

So far, I checked the port so only one option
Code:
echo-e "Port $port is:` head wyn1.log `" >> end.log

but I want to query enough clicks away at the same time my question.


Know, words will be repeated in a different order, and will focus on different ports.
# 6  
Old 10-19-2009
Instead of "head wyn1.log" try:
Code:
awk NR==$port wyn1.log

or
Code:
sed -n ${port}p wyn1.log

or
Code:
sed $port\!d wyn1.log


Last edited by Scrutinizer; 10-19-2009 at 07:39 PM..
# 7  
Old 10-20-2009
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

3. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

4. Shell Programming and Scripting

Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this > sat#16 #data: 15 site:UNZA baseline: 205.9151 0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722 0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies

5. Shell Programming and Scripting

How to delete lines of a text file based on another text file?

I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries. The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies

6. Shell Programming and Scripting

Read text between two lines containing a string

Hi, I have text file like the following: Start a b 121 c d End Start a 31 e f End Start p o i k (5 Replies)
Discussion started by: ysrini
5 Replies

7. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

8. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

9. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

10. Shell Programming and Scripting

Shell script to read lines in a text file and filter user data

hi all, I have this file with some user data. example: $cat myfile.txt FName|LName|Gender|Company|Branch|Bday|Salary|Age aaaa|bbbb|male|cccc|dddd|19900814|15000|20| eeee|asdg|male|gggg|ksgu|19911216||| aara|bdbm|male|kkkk|acke|19931018||23| asad|kfjg|male|kkkc|gkgg|19921213|14000|24|... (4 Replies)
Discussion started by: srimal
4 Replies
Login or Register to Ask a Question