Sponsored Content
Top Forums Shell Programming and Scripting Sort without Header and Trailer Post 302962264 by Saanvi1 on Thursday 10th of December 2015 02:52:27 PM
Old 12-10-2015
Code:
{ head -1 ; head -n-1 | sort -t"|" -k2,3; } < Test1.txt

Thanks for the reply. But the code is not working. Getting the error below:

head: Invalid "-n -1" option
usage: head [-n #] [-#] [filename...]

Thanks

---------- Post updated at 03:52 PM ---------- Previous update was at 03:50 PM ----------

Code:
{
read header; printf "%s\n" "$header"
sed '$d' | sort -t\| -k2,3
} < Test1.txt > Test2.txt

Thanks a bunch. The code above working fine for me.

I wanted to check if there is a way to output without header as well.

Thanks again.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Append Header and Trailer

Hi everyone, I am new to Unix programming. My inquries is:- a) How to add a Header and Trailer in the set of data b) Include a number count of the data in the trailer The set of data only contained the information of 'Customer's Name' and 'Account Number'. I would like to add the Header... (2 Replies)
Discussion started by: balzzz
2 Replies

2. Shell Programming and Scripting

Removing Header & Trailer from a file

Hi All, I am karthik. I am new to this forum. I have one requirement. I have a file with header and footer. Header may be like HDR0001 or FILE20090110 (Assume it is unknown so far, but i am sure there is a header in the file) likewise file has the trailer too. I just... (7 Replies)
Discussion started by: karthi_gana
7 Replies

3. Shell Programming and Scripting

Header as is.. trailer count

i have .DAT file FILE1.DAT 1200910270040625 2123456789 J123456 ABC 2123456789 K123456 ABC 2222222222 L123456 DEF 2333333333 M12345 GHI 30000004 My outfile FILE2.TXT should have like this, I need the header value as ie (1200910270040625 ) body rows remove the duplicate rows and the... (2 Replies)
Discussion started by: kshuser
2 Replies

4. UNIX for Dummies Questions & Answers

Adding header and trailer into a file

Hi, I want to add the below Header to all the files in sequence File1,File2,File3...etc "ABC,<number of chracter in the file>" e,g - If File1 is as below pqrstuvdt abcdefgh then I want to add the above header into it ,So that File1 becomes as below ABC,17 pqrstuvdt abcdefgh ... (9 Replies)
Discussion started by: spari2
9 Replies

5. UNIX for Dummies Questions & Answers

oneliner for adding header and trailer

for example, i have a file with below content: 123413 866688 816866 818818 i want the output as: This is header 123413 866688 816866 818818 This is trailer i am able to achieve it using a bash script. (2 Replies)
Discussion started by: pandeesh
2 Replies

6. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

7. Shell Programming and Scripting

Verify the header and trailer in file

please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies

8. Shell Programming and Scripting

Split and add header and trailer from input file

I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file Also is it possible to output the TOM and PAT records in the same output file ? I need the output file names same as xyz_pattern_Datetimestamp.txt ... (23 Replies)
Discussion started by: techedipro
23 Replies

9. UNIX for Advanced & Expert Users

Removing Header and Trailer record of a EBCDIC file

I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long. Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies

10. UNIX for Beginners Questions & Answers

Header and trailer Check in UNIX

I am planning to automate multiple files through Unix script. Could you please guide for making the automation for multiple files ? Eg. I have to check header and footer for all files in the particular path and the header pattern should match with the filename. Filename- Filename.txt... (2 Replies)
Discussion started by: karthick2020333
2 Replies
GET_ROBUST_LIST(2)						Linux System Calls						GET_ROBUST_LIST(2)

NAME
get_robust_list, set_robust_list - get/set list of robust futexes SYNOPSIS
#include <linux/futex.h> #include <syscall.h> long get_robust_list(int pid, struct robust_list_head **head_ptr, size_t *len_ptr); long set_robust_list(struct robust_list_head *head, size_t len); Note: There are no glibc wrappers for these system calls; see NOTES. DESCRIPTION
The robust futex implementation needs to maintain per-thread lists of robust futexes which are unlocked when the thread exits. These lists are managed in user space; the kernel is notified about only the location of the head of the list. The get_robust_list() system call returns the head of the robust futex list of the thread whose thread ID is specified in pid. If pid is 0, the head of the list for the calling thread is returned. The list head is stored in the location pointed to by head_ptr. The size of the object pointed to by **head_ptr is stored in len_ptr. The set_robust_list() system call requests the kernel to record the head of the list of robust futexes owned by the calling thread. The head argument is the list head to record. The len argument should be sizeof(*head). RETURN VALUE
The set_robust_list() and get_robust_list() system calls return zero when the operation is successful, an error code otherwise. ERRORS
The set_robust_list() system call can fail with the following error: EINVAL len does not match the size of structure struct robust_list_head expected by kernel. The get_robust_list() system call can fail with the following errors: EPERM The calling process does not have permission to see the robust futex list of the thread with the thread ID pid, and does not have the CAP_SYS_PTRACE capability. ESRCH No thread with the thread ID pid could be found. EFAULT The head of the robust futex list can't be stored at the location head. VERSIONS
These system calls were added in Linux 2.6.17. No library support is provided; use syscall(2). NOTES
These system calls are not needed by normal applications. No support for them is provided in glibc. In the unlikely event that you want to call them directly, use syscall(2). A thread can have only one robust futex list; therefore applications that wish to use this functionality should use the robust mutexes pro- vided by glibc. SEE ALSO
futex(2) Documentation/robust-futexes.txt and Documentation/robust-futex-ABI.txt in the Linux kernel source tree COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2012-07-13 GET_ROBUST_LIST(2)
All times are GMT -4. The time now is 04:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy