Sponsored Content
Top Forums Shell Programming and Scripting Grep content between specific lines Post 302918280 by Veera_V on Monday 22nd of September 2014 03:32:38 PM
Old 09-22-2014
below idea I have to go with (without using awk ). I am trying make script short and give exact results.

Code:
cat -n header > file1

cat file1

1:15:SCHEMA.TABLE1  
2:25:SCHEMA.TABLE2
3:30:SCHEMA.TABLE3
4:46:SCHEMA.TABLE3

MAX=`$( wc -l < file1 )`

cat file1 |while read line

do

SEQ=`echo $line |cut -d':' -f1`
STR=`echo $line |cut -d':' -f2`
TBL=`echo $line |cut -d':' -f3`

if [ SEQ -eq $MAX ];then

sed '$STR,$n,p' content.txt > $TBL.txt

else

SEQ=SEQ+1

END=`grep -"^$SEQ:" file1 |cut -d':' -f2`

END=`expr $END - 1` 

sed '$STR,$END,p' content.txt > $TBL.txt

fi


done


Last edited by Veera_V; 09-22-2014 at 04:54 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retreive content between specific lines ina file

Hi I have a text file which has two sets of lines repeating for "n" number of times.Some data is printed between the two lines.I want to retrieve all the data thats there in between those two set of lines.I have the string value of those two set of lines. To be much more clearer ... (4 Replies)
Discussion started by: chennaitomcruis
4 Replies

2. Shell Programming and Scripting

retrieving specific lines from a file - can I use grep ?

Hi there, if i had a file that looked like this my_server1 red green blue yellow blue my_server2 blue blue yellow green blue my_server3 yellow (9 Replies)
Discussion started by: hcclnoodles
9 Replies

3. UNIX Desktop Questions & Answers

grep lines with two specific characters somewhere in the line

I'm having trouble with extracting certain lines from a file based on whether they have all the required fields. Original file: snt:594:Sam N This bpt:2342:Bob P That lr:123 wrp:23:Whoever Person cor:794 Desired output: snt:594:Sam N This bpt:2342:Bob P That wrp:23:Whoever Person ... (3 Replies)
Discussion started by: Chthonic
3 Replies

4. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

5. Shell Programming and Scripting

Problems to print specific lines with awk and grep...HELP!

Hi all I have data like this: model: 1, misfit value: 0.74987 1 1.182 1.735 2.056 1.867 2 0.503 1.843 2.018 1.888 3 2.706 2.952 2.979 1.882 4 8.015 3.414 3.675 1.874 ... (1 Reply)
Discussion started by: fedora2011
1 Replies

6. Shell Programming and Scripting

Grep only specific lines ordered by column/date

Hi everybody, I'd like to think I've been through the search tool not only on this site, but also on google too, but I haven't been able to find what I was looking for. If I might've missed something on this forum, please slap me in the face with a link that you consider useful for my query :D ... (4 Replies)
Discussion started by: dilibau
4 Replies

7. Shell Programming and Scripting

grep the output between specific lines

Symmetrix ID : 00000001234 Host Name : myown Identifiers Found : 5000000000000000 5000000000000001 Device Cap(MB) Attr Dir:P ------ ------- ---- ---- 1234 25886 (M) 8D:1, 9D:1 0123 25886 (M) 8D:1, 9D:1 1345 25886 (M) ... (5 Replies)
Discussion started by: maddy.san
5 Replies

8. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

9. Shell Programming and Scripting

Display specific lines content from the file

Hell, I want to grep certain word from file and display above 2 lines and after two lines. Here is the content of sample file. Mar 14, 2013 12:56:59 AM Agent.Agent SendTo INFO: Connection to server:7041 - Credential Transmit Successesful Mar 14, 2013 8:54:21 AM cgent SendTo WARNING:... (7 Replies)
Discussion started by: balareddy
7 Replies

10. UNIX for Dummies Questions & Answers

Grep specific lines

Hello I have a file with nearly 90000 lines in x,y,z format but have some lines that I do not need to show. Is there anyway to delete those 3 lines after every 288 lines. Eg I keep the first 288 lines delete (289, 290 291); keep the next 288 lines after those and so on... Thanks (6 Replies)
Discussion started by: Madiouma Ndiaye
6 Replies
VARNISH-COUNTERS(7)													       VARNISH-COUNTERS(7)

NAME
varnish-counters - Varnish counter field definitions MAIN COUNTERS
client_conn - Client connections accepted client_drop - Connection dropped, no sess/wrk client_req - Client requests received cache_hit - Cache hits cache_hitpass - Cache hits for pass cache_miss - Cache misses backend_conn - Backend conn. success backend_unhealthy - Backend conn. not attempted backend_busy - Backend conn. too many backend_fail - Backend conn. failures backend_reuse - Backend conn. reuses backend_toolate - Backend conn. was closed backend_recycle - Backend conn. recycles backend_retry - Backend conn. retry fetch_head - Fetch head fetch_length - Fetch with Length fetch_chunked - Fetch chunked fetch_eof - Fetch EOF fetch_bad - Fetch had bad headers fetch_close - Fetch wanted close fetch_oldhttp - Fetch pre HTTP/1.1 closed fetch_zero - Fetch zero len fetch_failed - Fetch failed fetch_1xx - Fetch no body (1xx) fetch_204 - Fetch no body (204) fetch_304 - Fetch no body (304) n_sess_mem - N struct sess_mem n_sess - N struct sess n_object - N struct object n_vampireobject - N unresurrected objects n_objectcore - N struct objectcore n_objecthead - N struct objecthead n_waitinglist - N struct waitinglist n_vbc - N struct vbc n_wrk - N worker threads n_wrk_create - N worker threads created n_wrk_failed - N worker threads not created n_wrk_max - N worker threads limited n_wrk_lqueue - work request queue length n_wrk_queued - N queued work requests n_wrk_drop - N dropped work requests n_backend - N backends n_expired - N expired objects n_lru_nuked - N LRU nuked objects n_lru_moved - N LRU moved objects losthdr - HTTP header overflows n_objsendfile - Objects sent with sendfile n_objwrite - Objects sent with write n_objoverflow - Objects overflowing workspace s_sess - Total Sessions s_req - Total Requests s_pipe - Total pipe s_pass - Total pass s_fetch - Total fetch s_hdrbytes - Total header bytes s_bodybytes - Total body bytes sess_closed - Session Closed sess_pipeline - Session Pipeline sess_readahead - Session Read Ahead sess_linger - Session Linger sess_herd - Session herd shm_records - SHM records shm_writes - SHM writes shm_flushes - SHM flushes due to overflow shm_cont - SHM MTX contention shm_cycles - SHM cycles through buffer sms_nreq - SMS allocator requests sms_nobj - SMS outstanding allocations sms_nbytes - SMS outstanding bytes sms_balloc - SMS bytes allocated sms_bfree - SMS bytes freed backend_req - Backend requests made n_vcl - N vcl total n_vcl_avail - N vcl available n_vcl_discard - N vcl discarded n_ban - N total active bans n_ban_add - N new bans added n_ban_retire - N old bans deleted n_ban_obj_test - N objects tested n_ban_re_test - N regexps tested against n_ban_dups - N duplicate bans removed hcb_nolock - HCB Lookups without lock hcb_lock - HCB Lookups with lock hcb_insert - HCB Inserts esi_errors - ESI parse errors (unlock) esi_warnings - ESI parse warnings (unlock) accept_fail - Accept failures client_drop_late - Connection dropped late uptime - Client uptime dir_dns_lookups - DNS director lookups dir_dns_failed - DNS director failed lookups dir_dns_hit - DNS director cached lookups hit dir_dns_cache_full - DNS director full dnscache vmods - Loaded VMODs n_gzip - Gzip operations n_gunzip - Gunzip operations LOCK COUNTERS
creat - Created locks destroy - Destroyed locks locks - Lock Operations colls - Collisions PER MALLOC STORAGE COUNTERS
c_req - Allocator requests c_fail - Allocator failures c_bytes - Bytes allocated c_freed - Bytes freed g_alloc - Allocations outstanding g_bytes - Bytes outstanding g_space - Bytes available PER FILE STORAGE COUNTERS
c_req - Allocator requests c_fail - Allocator failures c_bytes - Bytes allocated c_freed - Bytes freed g_alloc - Allocations outstanding g_bytes - Bytes outstanding g_space - Bytes available g_smf - N struct smf g_smf_frag - N small free smf g_smf_large - N large free smf PER BACKEND COUNTERS
vcls - VCL references happy - Happy health probes AUTHOR
Tollef Fog Heen 1.0 2011-09-20 VARNISH-COUNTERS(7)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy