Sponsored Content
Top Forums Shell Programming and Scripting Adding lines to files based on file extension Post 302433449 by Xterra on Tuesday 29th of June 2010 08:27:21 PM
Old 06-29-2010
Adding lines to files based on file extension

I have posted this before but did not get many replies, so here it goes again.
I have several files name like this
Quote:
Pat1.1a
Patient32.1a
Pat16.3
Sample76.4
Pat243.5
Pat101.1a
Individual33.6
Pat93.2
Pat5.1b
If the file extension is 1a, I woould like to add at the beggining of the file the following sequence
Quote:
>Reference1a
AGCATGACGATCAGTGTGCGGGTGA
If the file extension is 1b, thn the entry that should be added is the next one
Quote:
>Reference1b
AGCATGTGTGCGGGTGA
So on and so forth.
I came out with the following code, which is working, but I was hoping there was a way to do the same thing using awk
Code:
#!/bin/sh
for f in *.1a
do
printf ">Reference1a\nTTGATGTGCCAACTGCGCAAATAGCAGCAGCACTACCAGGACCTTCGCCCA\n" | cat - ${f} > Converted${f}
done
for i in *.1b
do
printf ">Reference1b\nTTGATGTGCCTACCAGGACCTTCGCCCA\n" | cat - ${i} > Converted${i}
done
for e in *.3
do
printf ">Reference3\nTTGATTCGCCCA\n" | cat - ${e} > Converted${e}
done

Any ideas?
Thansk!

---------- Post updated at 08:27 PM ---------- Previous update was at 05:25 PM ----------

Anyone?

Last edited by Xterra; 06-29-2010 at 06:49 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

deleting lines from a delimited files based on a 2nd file

I need a little help... I have a file with 3 fields, Time/Date, IP address, UniqueID I have a 2nd file of UniqueIDs. I want to either (which ever is easier): 1. delete entries in file 1 that have a UniqueID in file 2 2. create a new file with the fields from File 1, excluding the... (4 Replies)
Discussion started by: goldie363
4 Replies

2. Shell Programming and Scripting

How to split a file with adding sequence number and extension.

I have a file name -HRCFTSIN05PLA1602100430444444 my requirement is to split the file in 10000 count each file and to add sequence number.rch at the end of each file. output should be in this format HRCFTSIN05PLA160210043044444401.rch HRCFTSIN05PLA160210043044444402.rch... (4 Replies)
Discussion started by: abhigrkist
4 Replies

3. Shell Programming and Scripting

Adding lines to files based on their names

I have several files on a folder something like this: If the file starts with 1a, I would like to add the following at the very beggining of the file If the file starts with 1b then I should add the following For files starting with 6 So on and so forth. Thus, at the end each file will... (18 Replies)
Discussion started by: Xterra
18 Replies

4. Shell Programming and Scripting

Adding the data before file extension

HI , I have a file with multiple lines like below, I need to check on column starting with #prototype if it has the .Number.txt extension do nothing else add 1.txt extension. Source data Jdbc_app_data :- sample data #prototype= sample data from test.1.txt application_id=122135... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

5. Shell Programming and Scripting

Adding number before file extension

Hi , I have a file which has a line starts with $segment_name and has the below data source data $Segment_Name = 123.ABC.123.01.txt $Segment_Name = 123.ABC.ABC.txt $Segment_Name = 123.ABC.12A3.txtMy target data should be $Segment_Name = 123.ABC.123.01.txt $Segment_Name =... (2 Replies)
Discussion started by: shruthidwh
2 Replies

6. Shell Programming and Scripting

Generate files from one file based on lines

Hi Friends, I have a file1 file1.txt 1ABC 13478 aqjerh 473 343 2hej 478 5775 24578 23892 3fhd fg 847 brjkb f99345 487 4eh ehjk 84 47589 8947 234 5784 487 738 52895 8975 6 57489 eghe9 4575 859479 7fnbd 4y5 4iuy 458 h irh 8fjdg 74 7845 8475 5789 94yr 48yr 4hr erhj reh... (3 Replies)
Discussion started by: i150371485
3 Replies

7. Shell Programming and Scripting

Delete specific lines from files based on another file

I have some text files in a folder named ff as follows. I need to delete the lines (in-place editing)in these files based on another file aa.txt. 32bm.txt: 249 253 A P - 0 0 8 0, 0.0 6,-1.4 0, 0.0 2,-0.4 -0.287 25.6-102.0 -74.4 161.1 37.1 13.3 10.9 250... (2 Replies)
Discussion started by: aden
2 Replies

8. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

9. Shell Programming and Scripting

Conditional deletion of files based on extension

Hello All, I have some files like file, file.chk, file.sem and file.temp in huge. I would like to delete some files based on following criteria. 1. Unconditionally delete .sem and .temp files 2. If we found the actual file, don't remove .chk file, otherwise remove .chk file as well for... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

10. Shell Programming and Scripting

Copy files based on specific word in a file name & its extension and putting it in required location

Hello All, Since i'm relatively new in shell script need your guidance. I'm copying files manually based on a specific word in a file name and its extension and then moving it into some destination folder. so if filename contains hyr word and it has .md and .db extension; it will move to TUM/HYR... (13 Replies)
Discussion started by: prajaktaraut
13 Replies
NYSHELL(1)						      General Commands Manual							NYSHELL(1)

NAME
nyshell - tool to generate shell scripts to build nypatchy output SYNOPSIS
nyshell logfile options cradle [ print ] [ .go ] DESCRIPTION
nyshell is a tool in the Nypatchy suite of programs for working with Patchy Master Files (PAM files); see nypatchy(1). Specifically, given the log file of a nypatchy run, it can create a shell script to compile all the source code files output by nypatchy. This program is sim- ilar to fcasplit except that it takes the log file as input instead of a source file, and it remembers which source code files have already been compiled in previous runs. USAGE
logfile is the name of the log file coming from nypatchy, with a default extension of ".log". A cradle file cradle may be given to add additional setup options such as desired compilers or compiler flags to use. (See the reference manual for more details.) print is the file to which informational output should be written (the default is standard output if omitted), and options is a sequence of single-char- acter flags. This program generates a shell script file named name.shfca (with name being the part of logfile sans extension) that can be run to build all object files. The file name.xqtlog "remembers" the current state. The command should be ended with ".go" unless one wants to enter the Nypatchy interactive shell. OPTIONS
Note that options should be given as a single string of characters with no space separation and no use of the - character (except that it can be used in place of the options field if no options are desired). Alphabetic options are not case-sensitive. A Force recompilation of all routines. B Bypass tests based on the .xqtlog file. E Bypass tests based on the .xqtlog file if it is empty. H Print help information only. Q "quick" - Do not print the setup. S Print the setup only (only together with H). U "up to date" - Check that all .o files are ready to go into a library. V "verbose" - Print the complete setup. SEE ALSO
fcasplit(1), nycheck(1), nydiff(1), nyindex(1), nylist(1), nypatchy(1), nymerge(1), nysynopt(1), nytidy(1), yexpand(1) The reference manual for the Nypatchy suite of programs is available in compressed PostScript format at the following URL: http://wwwasdoc.web.cern.ch/wwwasdoc/psdir/p5refman.ps.gz Running the command "nyshell help .no" also gives some brief help on usage. Running the command "nyshell - hs .no" prints the default set- up (compiler names and options) to be used in the generated shell scripts. AUTHOR
This manual page was written by Kevin McCarty <kmccarty@debian.org> for the Debian GNU/Linux system (but may be used by others). It is licensed under the GNU General Public License, version 2 or later (at your choice). COPYRIGHT
Copyright (C) Kevin B. McCarty, 2008. Mar 12, 2008 NYSHELL(1)
All times are GMT -4. The time now is 09:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy