Sponsored Content
Top Forums Shell Programming and Scripting append text to column in all files of directory Post 302656807 by alpesh on Friday 15th of June 2012 12:19:56 PM
Old 06-15-2012
Hi Methyl and Ranga,

I`m sorry for the inconvenience and many thanks for the help.

I`m using Red Hat Enterprise Linux 6 unix bash, thats all i know.

I have included the input and output this time. I need to do this with all files in the directory.

Input

Code:
Bak-2   1       711     T       C       38      6       1       1.28571
Bak-2   1       892     T       G       38      5       1       1
Bak-2   1       3279    G       T       30      3       1       1

Expected output

Code:
Bak-2   chr1       711     T       C       38      6       1       1.28571
Bak-2   chr1       892     T       G       38      5       1       1
Bak-2   chr1       3279    G       T       30      3       1       1

Ranga,

I ran your code, it is doing an infinite loop the printing line1 for file1 repeatedly.
Also I changed the delimiter to tabbed and used BEGIN{FS="\t";} in your code.

Output from Ranga`s code

Code:
Bak-2 chr1 711 T C 38 6 1 1.28571
Bak-2 chr1 711 T C 38 6 1 1.28571
Bak-2 chr1 711 T C 38 6 1 1.28571
Bak-2 chr1 711 T C 38 6 1 1.28571

Please help
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

How to read and append certain files form directory

Hi ,i have a question ,if I am in sertain directory and I have 4 files *.c how can I read and append this files in file backup.bac Thanks find ./ -name "*.csh" | wc -l (2 Replies)
Discussion started by: lio123
2 Replies

3. UNIX for Dummies Questions & Answers

Append a line to single column text file

I would like to add a line to the end of a single column text file. How do I go about doing that? Input: BEGIN 1 2 3 Output: BEGIN 1 2 3 END Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

4. Shell Programming and Scripting

Append variable texts to the beginning of each line in all files in a directory

I am writing a code to append some numbers in the beginning of each line in all the files present in a directory. The number of files are really huge. The files are numbered as 1.sco, 2.sco, 4.sco (Note: 3.sco is missing). The files currently look like this: 1.sco 2 3 5 6 6 7My task is to... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

5. Shell Programming and Scripting

Compare a common field in two files and append a column from File 1 in File2

Hi Friends, I am new to Shell Scripting and need your help in the below situation. - I have two files (File 1 and File 2) and the contents of the files are mentioned below. - "Application handle" is the common field in both the files. (NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies

6. UNIX for Dummies Questions & Answers

Append text to files with a same pattern

Hi Folks, I wanted to know if i can use RegEx in a for-loop of a shell script. Here's a scenario, I have a set of files say x1, x2, x3..x9 in a directory(obviously with files other than this pattern). I want to append a line of text to all files that follow pattern x. Can someone help me out? I... (4 Replies)
Discussion started by: prithvirao17
4 Replies

7. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

8. UNIX for Dummies Questions & Answers

Append two lines of text to php.ini in the entire directory tree.e

I am looking to write a script that will read the php.ini files on my web host. If the two lines do exist do nothing. If not append two lines to the end of it then move on to the next directory and open the next php.ini file. I have the beginning of one that was given to me on another web site but... (6 Replies)
Discussion started by: Larrykh465
6 Replies

9. Shell Programming and Scripting

Append a specific keyword in a text file into a new column

All, I have some sample text file(.csv) in the below format. In my actual file there are at least 100K rows. date 03/25/2016 A,B,C D,E,F date 03/26/2016 1,2,3 4,5,6 date 03/27/2016 6,4,3 4,5,6 I require the following output where in the date appeared at different locations need to... (3 Replies)
Discussion started by: ks_reddy
3 Replies

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

Hi Experts Need help... I am looking for a Unix script to append pipe | at the end of all the rows (except header and trailer)in all the files placed under the directory /interfaces/Temp e.g. Header row1 row2 row3 Trailer The script should read all the files under... (3 Replies)
Discussion started by: phani333
3 Replies
mlib_SignalLinear2ALaw(3MLIB)				    mediaLib Library Functions				     mlib_SignalLinear2ALaw(3MLIB)

NAME
mlib_SignalLinear2ALaw - ITU G.711 m-law and A-law compression and decompression SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_SignalLinear2ALaw(mlib_u8 *acode, const mlib_s16 *pcm, mlib_s32 n); DESCRIPTION
The mlib_SignalLinear2ALaw() function performs ITU G.711 m-law and A-law compression and decompression in compliance with the ITU (Former CCITT) G.711 specification. PARAMETERS
The function takes the following arguments: acode A-law code array. pcm Linear PCM sample array. n Number of samples in the source array. RETURN VALUES
The function returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_SignalALaw2Linear(3MLIB), mlib_SignalALaw2uLaw(3MLIB), mlib_SignalLinear2uLaw(3MLIB), mlib_SignaluLaw2ALaw(3MLIB), mlib_Signalu- Law2Linear(3MLIB), attributes(5) SunOS 5.10 9 Nov 2004 mlib_SignalLinear2ALaw(3MLIB)
All times are GMT -4. The time now is 01:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy