Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Append pipe | at the end of all the rows except header n trailer for all the files under a directory Post 303039245 by RudiC on Friday 27th of September 2019 03:44:35 AM
Old 09-27-2019
Try with a shell loop:
Code:
for FN in *; do sed -n '1 {p;b;}; ${p;b;}; s/$/|/p;' $FN > new_$FN; done

EDIT: or,
Code:
for FN in *; do sed  '1bL; $bL; s/$/|/; :L' $FN; done


Last edited by RudiC; 09-27-2019 at 12:21 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy all the files with time stamp and remove header,trailer from file

All, I am new to unix and i have the following requirement. I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file.. Could... (35 Replies)
Discussion started by: ksrams
35 Replies

2. 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

3. Shell Programming and Scripting

Append Spaces At end of each line Leaving Header and Footer

How to append constant No of spaces suppose 52 at end of each line in a file (xyz) excluding first and last line. Please Help me out for the same. (1 Reply)
Discussion started by: deepam
1 Replies

4. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

5. Shell Programming and Scripting

search directory-find files-append at end of line

Hi, I have a command "get_data" with some parameters in few *.text files of a directory. I want to first find those files that contain this command and then append the following parameter to the end of the command. example of an entry in the file :- get_data -x -m50 /etc/web/getid this... (1 Reply)
Discussion started by: PrasannaKS
1 Replies

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Sort without Header and Trailer

Hi , My UNIX system is SUN Solaris. I am trying to do a simple thing as described below. I have a PIPE delimited file that has header and trailer. So the file is something like below: Test1.txt looks like something below: field_data1|field_data2|and some more data --Header ... (5 Replies)
Discussion started by: Saanvi1
5 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
PIPE(2) 							System Calls Manual							   PIPE(2)

NAME
pipe - create an interprocess communication channel SYNOPSIS
#include <unistd.h> int pipe(int fildes[2]) DESCRIPTION
The pipe system call creates an I/O mechanism called a pipe. The file descriptors returned can be used in read and write operations. When the pipe is written using the descriptor fildes[1] up to PIPE_MAX bytes of data are buffered before the writing process is suspended. A read using the descriptor fildes[0] will pick up the data. PIPE_MAX equals 7168 under Minix, but note that most systems use 4096. It is assumed that after the pipe has been set up, two (or more) cooperating processes (created by subsequent fork calls) will pass data through the pipe with read and write calls. The shell has a syntax to set up a linear array of processes connected by pipes. Read calls on an empty pipe (no buffered data) with only one end (all write file descriptors closed) returns an end-of-file. The signal SIGPIPE is generated if a write on a pipe with only one end is attempted. RETURN VALUE
The function value zero is returned if the pipe was created; -1 if an error occurred. ERRORS
The pipe call will fail if: [EMFILE] Too many descriptors are active. [ENFILE] The system file table is full. [ENOSPC] The pipe file system (usually the root file system) has no free inodes. [EFAULT] The fildes buffer is in an invalid area of the process's address space. SEE ALSO
sh(1), read(2), write(2), fork(2). NOTES
Writes may return ENOSPC errors if no pipe data can be buffered, because the pipe file system is full. BUGS
Should more than PIPE_MAX bytes be necessary in any pipe among a loop of processes, deadlock will occur. 4th Berkeley Distribution August 26, 1985 PIPE(2)
All times are GMT -4. The time now is 02:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy