06-11-2010
I will try this. One question though, which could be slightly stupid:
For example: head -100000 | tail -100000 | perl -e '....' > out.1
I know head -100000 = first 100000 lines of the file and
tail -100000 = last 100000 lines in the file...
but what lines are specified if you put both like you have done?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a small requirement in chainging the rows to columns. The below example.txt contains info as shown
Name:Person1
Age:30
Name:Person2
Age:40
Name:Person3
Age:50
I want to make it displayed as hown below
Name:Person1 Age:30
Name:person2 Age:40
Name:Person3 Age:50
I... (4 Replies)
Discussion started by: oracle123
4 Replies
2. Shell Programming and Scripting
Friends,
I have text file with 700,000 rows.
Once I load this file to our database via our cutom process, it logs the row number for rejected rows.
How do I delete rows from a Large text file based on the Row Number?
Thanks,
Prashant (8 Replies)
Discussion started by: ppat7046
8 Replies
3. Shell Programming and Scripting
Hi I have an input file and I want to transpose it but I need to take care that if any field is missing for a record it should be popoulated with space for that field - using a shell script
INFILE
----------
emp=1
sal=2
loc=abc
emp=2
sal=21
sal=22
loc=xyz
emp=5
loc=abc
OUTFILE... (10 Replies)
Discussion started by: 46019
10 Replies
4. Shell Programming and Scripting
Hi Guys,
I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language
the text file contains data in a pipe delimited format
sdfsdfs
sdfsdfsd
START_ROW
sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have a data file that contains 61 columns. I want to delete all the columns except columns, 3,6 and 8. The columns are tab de-limited. How would I achieve this on the terminal?
Thanks (2 Replies)
Discussion started by: lost.identity
2 Replies
6. Shell Programming and Scripting
Hello,
I have a huge tab delimited file with around 40,000 columns and 900 rows I want to convert columns to a row.
INPUT file look like this.
the first line is a headed of a file.
ID marker1 marker2 marker3 marker4
b1 A G A C ... (5 Replies)
Discussion started by: ryan9011
5 Replies
7. Shell Programming and Scripting
Hi, I have a large file with number of records in there. I need some help to find only first row based on a key and ignore other rows with the same key. I tried few things but file is huge(30 million rows). So need some solution that is very efficient.
e.g
Junk|Apple|7|Random|data|here...... (2 Replies)
Discussion started by: ran123
2 Replies
8. Shell Programming and Scripting
Hi Friends,
I have come across some files where some of the columns don not have data.
Key, Data1,Data2,Data3,Data4,Data5
A,5,6,,10,,
A,3,4,,3,,
B,1,,4,5,,
B,2,,3,4,,
If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies
9. UNIX for Dummies Questions & Answers
Hi everyone. I have a file with ~500 columns and I would like to perform a simple calculation on every two columns. The file looks like this:
$cat input
id A B C D E F.....X
1 2 4 2 3 4 1 n
2 4 6 4 6 4 5 n
3 4 7 5 2 2 3 n
4 ... (5 Replies)
Discussion started by: torchij
5 Replies
10. UNIX for Dummies Questions & Answers
Dear all,
I want to extract around 300 columns from a very large file with almost 2million columns. There are no headers, but I can find out which column numbers I want. I know I can extract with the function 'cut -f2' for example just the second column but how do I do this for such a large... (1 Reply)
Discussion started by: fndijk
1 Replies
testb(9F) Kernel Functions for Drivers testb(9F)
NAME
testb - check for an available buffer
SYNOPSIS
#include <sys/stream.h>
int testb(size_t size, uint_t pri);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
size Size of the requested buffer.
pri Priority of the allocb request.
DESCRIPTION
testb() checks to see if an allocb(9F) call is likely to succeed if a buffer of size bytes at priority pri is requested. Even if
testb() returns successfully, the call to allocb(9F) can fail. The pri argument is no longer used, but is retained for compatibility.
RETURN VALUES
Returns 1 if a buffer of the requested size is available, and 0 if one is not.
CONTEXT
testb() can be called from user or interrupt context.
EXAMPLES
Example 1: testb() example
In a service routine, if copymsg(9F) fails (line 6), the message is put back on the queue (line 7) and a routine, tryagain, is scheduled
to be run in one tenth of a second. Then the service routine returns.
When the timeout(9F) function runs, if there is no message on the front of the queue, it just returns. Otherwise, for each message block
in the first message, check to see if an allocation would succeed. If the number of message blocks equals the number we can allocate, then
enable the service procedure. Otherwise, reschedule tryagain to run again in another tenth of a second. Note that tryagain is merely an
approximation. Its accounting may be faulty. Consider the case of a message comprised of two 1024-byte message blocks. If there is only
one free 1024-byte message block and no free 2048-byte message blocks, then testb() will still succeed twice. If no message blocks are
freed of these sizes before the service procedure runs again, then the copymsg(9F) will still fail. The reason testb() is used here is
because it is significantly faster than calling copymsg. We must minimize the amount of time spent in a timeout() routine.
1 xxxsrv(q)
2 queue_t *q;
3 {
4 mblk_t *mp;
5 mblk_t *nmp;
. . .
6 if ((nmp = copymsg(mp)) == NULL) {
7 putbq(q, mp);
8 timeout(tryagain, (intptr_t)q, drv_usectohz(100000));
9 return;
10 }
. . .
11 }
12
13 tryagain(q)
14 queue_t *q;
15 {
16 register int can_alloc = 0;
17 register int num_blks = 0;
18 register mblk_t *mp;
19
20 if (!q->q_first)
21 return;
22 for (mp = q->q_first; mp; mp = mp->b_cont) {
23 num_blks++;
24 can_alloc += testb((mp->b_datap->db_lim -
25 mp->b_datap->db_base), BPRI_MED);
26 }
27 if (num_blks == can_alloc)
28 qenable(q);
29 else
30 timeout(tryagain, (intptr_t)q, drv_usectohz(100000));
31 }
SEE ALSO
allocb(9F), bufcall(9F), copymsg(9F), timeout(9F)
Writing Device Drivers
STREAMS Programming Guide
NOTES
The pri argument is provided for compatibility only. Its value is ignored.
SunOS 5.10 11 Nov 1996 testb(9F)