help with displaying certain lines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with displaying certain lines
# 1  
Old 07-26-2001
help with displaying certain lines

suppose i have a file which contains this:
00 07 * * * /home/production/bin/xxx.ksh
00 08 * * * /home/production/bin/xyz.ksh
00 12 * * * /home/production/bin/tuv.ksh
30 06 * * * /home/production/bin/cde.ksh
30 10 * * * /home/production/bin/put.ksh
00 01 * * * /home/production/bin/lik.sh

Now if I WANT TO DISPLAY ONLY THOSE LINES WHICH HAVE SECOND COLUMN >=06 AND <12.hOW DO i DO IT.

Thanks in advance.Smilie
# 2  
Old 07-26-2001
Tools

cut -f2 -d" " file1 > file2

This will put just that column into file2.

I'm sure there are other solutions out there as well, but I hope this helps.

Radimus
# 3  
Old 07-27-2001
hi

Try giving this
awk '$2 >= 06 && $2 < 12 {print}' test.txt
test.txt is the file which will contain
00 07 * * * /home/production/bin/xxx.ksh
00 08 * * * /home/production/bin/xyz.ksh
00 12 * * * /home/production/bin/tuv.ksh
30 06 * * * /home/production/bin/cde.ksh
30 10 * * * /home/production/bin/put.ksh
00 01 * * * /home/production/bin/lik.sh

# 4  
Old 07-27-2001
Thanks Smilie
It was a real good help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Displaying all the lines starting with some keyword

consider the contents of a file has many stuff including few stuff that i need.. so i perfromed the below function cat filename | grep "ALTER TABLE" its output is as shown below . . . . . SET @sql:=CONCAT('ALTER TABLE RecordMixProfile AUTO_INCREMENT=', @maxId) ; SET... (14 Replies)
Discussion started by: vivek d r
14 Replies

2. Shell Programming and Scripting

displaying multiple lines using AWk

say I'm doing awk 'NR==534' Is there a way to display 534 535 536 537? without appending to a variable? per line? maybe an easier way with a different command? My first impression was NR==534-537 but that would be too easy :P (2 Replies)
Discussion started by: puttster
2 Replies

3. Shell Programming and Scripting

Displaying lines of a file which have the highest number?

Hello Wondering if anybody may be able to advise on how I can filter the contents of the following file: <object_name>-<version> <Instance> GM_GUI_code.fmb-4 1 GM_GUI_code.fmb-5 1 GM_GUI_code.fmx-4 ... (7 Replies)
Discussion started by: Glyn_Mo
7 Replies

4. Homework & Coursework Questions

Displaying specific lines from a CSV file

1. The problem statement, all variables and given/known data: Display from a csv file, birthdays that occur today. If there are no birthdays today, the next one in the year. 2. Relevant commands, code, scripts, algorithms: The csv file is ordered from older to younger (ie. the most recent... (8 Replies)
Discussion started by: Adzi
8 Replies

5. Shell Programming and Scripting

Displaying lines of a file where the second field matches a pattern

Howdy. I know this is most likely possible using sed or awk or grep, most likely a combination of them together, but how would one go about running a grep like command on a file where you only try to match your pattern to the second field in a line, space delimited? Example: You are... (3 Replies)
Discussion started by: LordJezoX
3 Replies

6. Shell Programming and Scripting

Displaying number of lines from file

Hi, I am using below command to display the number of line, but its returning no of lines along with file name. But i want only no of line in the variable p. Please help me on this? p=`wc -l "text file"` echo "$p" (6 Replies)
Discussion started by: shivanete
6 Replies

7. Shell Programming and Scripting

Help required in displaying lines exceeding 79 chars along with their line numbers ??

Hi folks, I am looking for a solution to display those lines in any file that contains 80 or more characters along with their corresponding line number in the file. The below script will print the lines with their corresponding line numbers... sed = Sample.cpp | sed 'N;s/\n/\t/;... (8 Replies)
Discussion started by: frozensmilz
8 Replies

8. UNIX for Dummies Questions & Answers

Displaying specific lines in a file.

I'm trying to figure out how to display a certain line in a text file. I keep getting references to Tail and Head, and I know how these work, but i'm lost on how to find say the third out of the five lines and display only that. I thought maybe grep could help, but that doesn't seem likely. ... (3 Replies)
Discussion started by: MaestroRage
3 Replies

9. Shell Programming and Scripting

displaying/ counting lines

I have a file called xx with the env redirected into it 5 times: env >> xx env >> xx env >> xx env >> xx env >> xx I have to read an input file (here: xx) and look for occurrences of the current user who is executing this script. Once finding an occurrence of the username I have to take that... (2 Replies)
Discussion started by: aga
2 Replies

10. UNIX for Dummies Questions & Answers

displaying/ counting lines

I have a file called xx with the env redirected into it 5 times: env >> xx env >> xx env >> xx env >> xx env >> xx I have to read an input file (here: xx) and look for occurrences of the current user who is executing this script. Once finding an occurrence of the username I have to take that... (4 Replies)
Discussion started by: aga
4 Replies
Login or Register to Ask a Question