Sponsored Content
Top Forums UNIX for Dummies Questions & Answers What should be precedence of using awk, sed, head and tail in UNIX? Post 302801031 by fpmurphy on Wednesday 1st of May 2013 06:32:04 AM
Old 05-01-2013
As hanson44 said, there is no hard and fast rule. Just use the utility that you are most familiar with so that you get the task completed in the shortest amount of time.
This User Gave Thanks to fpmurphy For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Implementing MORE,HEAD & TAIL

hai in my shell script i want to replace the following commands 1) more 2) head 3) tail i want to try all type of possible options avaliabul in the above commands please help in implementing those commands (9 Replies)
Discussion started by: g_s_r_c
9 Replies

2. UNIX for Dummies Questions & Answers

head & tail

I've a major file which includes other files and now I wanna 'cut' the file in several minor parts....like .... find / -name "*.tmp" >filea wc -l filea >fileb sed -e '1s/ filea//' fileb >filec AMOUNT=`cat filec` if ; then cat file a |head -100l (ell) |tail -100l >filec cat file a |head... (6 Replies)
Discussion started by: svennie
6 Replies

3. Shell Programming and Scripting

Head and Tail in One Line

I am new to UNIX......I have one file which contains thousnads of records with header and tailer. Header Record 1 Record 2 .... .... Last Record Trailer I want to concatenate Header and Trailer in the first line....now the output should look like this: Header: Header value, Trailer:... (2 Replies)
Discussion started by: 33junaid
2 Replies

4. Shell Programming and Scripting

Imitate head and tail command script

Hi, I have been given assignment of 30 scripts out of which I was able to solve many, I need help with few out of which one asks to imitate head and tail command of unix without using the head and tail commands. Problem is stated below: Write an interactive shell script to imitate the head... (5 Replies)
Discussion started by: nutalk
5 Replies

5. Shell Programming and Scripting

Averaging in increments using awk & head/tail

Hi, I only have a very limited understanding and experience with writing code and I was hoping I could get some help. I have a dataset of two columns (txt format, numbers in each row separated by a tab) Eg. 1 5 2 5 3 6 4 7 5 6 6 6 7 ... (5 Replies)
Discussion started by: Emred_Skye
5 Replies

6. Shell Programming and Scripting

head / tail combination returns multiple rows

Hi, As part of our project, we need to load historical data for a year before our system is live. We have the data feed files that we need to load. However, I need to make sure that the file structure (number of fields separated by a comma) on the field is same for all the files of the same... (1 Reply)
Discussion started by: raj.jha
1 Replies

7. UNIX for Dummies Questions & Answers

head\tail how to display middle lines

hay i need to display middle line: 1 2 3 4 5 how can i display 3-4? (6 Replies)
Discussion started by: margan_ron
6 Replies

8. Homework & Coursework Questions

Head Tail Problem

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: view the 7th line of the program xxx.sh 2. Relevant commands, code, scripts, algorithms: head command tail... (10 Replies)
Discussion started by: hbell221
10 Replies

9. Homework & Coursework Questions

How to display certain line of file only using head or tail in 1 command?

First month learning about the Linux terminal and it has been a challenge yet fun so far. We're learning by using a gameshell. I'm trying to display a certain line ( only allowed 1 command ) from a file only using the head or tail. I'm pretty about this answer: head -23 history.txt | tail -1... (1 Reply)
Discussion started by: forzatekk
1 Replies
TASKQUEUE(9)						   BSD Kernel Developer's Manual					      TASKQUEUE(9)

NAME
taskqueue -- asynchronous task execution SYNOPSIS
#include <sys/param.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/queue.h> #include <sys/taskqueue.h> typedef void (*task_fn_t)(void *context, int pending); typedef void (*taskqueue_enqueue_fn)(void *context); struct task { STAILQ_ENTRY(task) ta_link; /* link for queue */ u_short ta_pending; /* count times queued */ u_short ta_priority; /* priority of task in queue */ task_fn_t ta_func; /* task handler */ void *ta_context; /* argument for handler */ }; struct taskqueue * taskqueue_create(const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context); struct taskqueue * taskqueue_create_fast(const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context); void taskqueue_free(struct taskqueue *queue); int taskqueue_enqueue(struct taskqueue *queue, struct task *task); int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task); void taskqueue_run(struct taskqueue *queue); void taskqueue_run_fast(struct taskqueue *queue); void taskqueue_drain(struct taskqueue *queue, struct task *task); int taskqueue_member(struct taskqueue *queue, struct thread *td); TASK_INIT(struct task *task, int priority, task_fn_t *func, void *context); TASKQUEUE_DECLARE(name); TASKQUEUE_DEFINE(name, taskqueue_enqueue_fn enqueue, void *context, init); TASKQUEUE_FAST_DEFINE(name, taskqueue_enqueue_fn enqueue, void *context, init); TASKQUEUE_DEFINE_THREAD(name); TASKQUEUE_FAST_DEFINE_THREAD(name); DESCRIPTION
These functions provide a simple interface for asynchronous execution of code. The function taskqueue_create() is used to create new queues. The arguments to taskqueue_create() include a name that should be unique, a set of malloc(9) flags that specify whether the call to malloc() is allowed to sleep, a function that is called from taskqueue_enqueue() when a task is added to the queue, and a pointer to the memory location where the identity of the thread that services the queue is recorded. The function called from taskqueue_enqueue() must arrange for the queue to be processed (for instance by scheduling a software interrupt or wak- ing a kernel thread). The memory location where the thread identity is recorded is used to signal the service thread(s) to terminate--when this value is set to zero and the thread is signaled it will terminate. If the queue is intended for use in fast interrupt handlers taskqueue_create_fast() should be used in place of taskqueue_create(). The function taskqueue_free() should be used to free the memory used by the queue. Any tasks that are on the queue will be executed at this time after which the thread servicing the queue will be signaled that it should exit. To add a task to the list of tasks queued on a taskqueue, call taskqueue_enqueue() with pointers to the queue and task. If the task's ta_pending field is non-zero, then it is simply incremented to reflect the number of times the task was enqueued. Otherwise, the task is added to the list before the first task which has a lower ta_priority value or at the end of the list if no tasks have a lower priority. Enqueueing a task does not perform any memory allocation which makes it suitable for calling from an interrupt handler. This function will return EPIPE if the queue is being freed. The function taskqueue_enqueue_fast() should be used in place of taskqueue_enqueue() when the enqueuing must happen from a fast interrupt handler. This method uses spin locks to avoid the possibility of sleeping in the fast interrupt context. To execute all the tasks on a queue, call taskqueue_run() or taskqueue_run_fast() depending on the flavour of the queue. When a task is exe- cuted, first it is removed from the queue, the value of ta_pending is recorded and then the field is zeroed. The function ta_func from the task structure is called with the value of the field ta_context as its first argument and the value of ta_pending as its second argument. After the function ta_func returns, wakeup(9) is called on the task pointer passed to taskqueue_enqueue(). The taskqueue_drain() function is used to wait for the task to finish. There is no guarantee that the task will not be enqueued after call to taskqueue_drain(). The taskqueue_member() function returns 1 if the given thread td is part of the given taskqeueue queue and 0 otherwise. A convenience macro, TASK_INIT(task, priority, func, context) is provided to initialise a task structure. The values of priority, func, and context are simply copied into the task structure fields and the ta_pending field is cleared. Five macros TASKQUEUE_DECLARE(name), TASKQUEUE_DEFINE(name, enqueue, context, init), TASKQUEUE_FAST_DEFINE(name, enqueue, context, init), and TASKQUEUE_DEFINE_THREAD(name) TASKQUEUE_FAST_DEFINE_THREAD(name) are used to declare a reference to a global queue, to define the implementa- tion of the queue, and declare a queue that uses its own thread. The TASKQUEUE_DEFINE() macro arranges to call taskqueue_create() with the values of its name, enqueue and context arguments during system initialisation. After calling taskqueue_create(), the init argument to the macro is executed as a C statement, allowing any further initialisation to be performed (such as registering an interrupt handler etc.) The TASKQUEUE_DEFINE_THREAD() macro defines a new taskqueue with its own kernel thread to serve tasks. The variable struct taskqueue *taskqueue_name is used to enqueue tasks onto the queue. TASKQUEUE_FAST_DEFINE() and TASKQUEUE_FAST_DEFINE_THREAD() act just like TASKQUEUE_DEFINE() and TASKQUEUE_DEFINE_THREAD() respectively but taskqueue is created with taskqueue_create_fast(). Predefined Task Queues The system provides four global taskqueues, taskqueue_fast, taskqueue_swi, taskqueue_swi_giant, and taskqueue_thread. The taskqueue_fast queue is for swi handlers dispatched from fast interrupt handlers, where sleep mutexes cannot be used. The swi taskqueues are run via a software interrupt mechanism. The taskqueue_swi queue runs without the protection of the Giant kernel lock, and the taskqueue_swi_giant queue runs with the protection of the Giant kernel lock. The thread taskqueue taskqueue_thread runs in a kernel thread context, and tasks run from this thread do not run under the Giant kernel lock. If the caller wants to run under Giant, he should explicitly acquire and release Giant in his taskqueue handler routine. To use these queues, call taskqueue_enqueue() with the value of the global taskqueue variable for the queue you wish to use (taskqueue_swi, taskqueue_swi_giant, or taskqueue_thread). Use taskqueue_enqueue_fast() for the global taskqueue variable taskqueue_fast. The software interrupt queues can be used, for instance, for implementing interrupt handlers which must perform a significant amount of pro- cessing in the handler. The hardware interrupt handler would perform minimal processing of the interrupt and then enqueue a task to finish the work. This reduces to a minimum the amount of time spent with interrupts disabled. The thread queue can be used, for instance, by interrupt level routines that need to call kernel functions that do things that can only be done from a thread context. (e.g., call malloc with the M_WAITOK flag.) Note that tasks queued on shared taskqueues such as taskqueue_swi may be delayed an indeterminate amount of time before execution. If queue- ing delays cannot be tolerated then a private taskqueue should be created with a dedicated processing thread. SEE ALSO
ithread(9), kthread(9), swi(9) HISTORY
This interface first appeared in FreeBSD 5.0. There is a similar facility called tqueue in the Linux kernel. AUTHORS
This manual page was written by Doug Rabson. BSD
August 18, 2009 BSD
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy