Sponsored Content
Top Forums Shell Programming and Scripting Rename text file with a specific pattern in directory Post 302991356 by cmccabe on Thursday 9th of February 2017 01:09:38 PM
Old 02-09-2017
Rename text file with a specific pattern in directory

I am trying to rename all text files in a directory that match a pattern. The current command below seems to be using the directory path in the name and since it already exists, will not do the rename. I am not sure what I am missing? Thank you Smilie.


Files to rename in /home/cmccabe/Desktop/test/vcf/overall/annovar
Code:
16-0000_File-A_variant_strandbias_readcount.vcf.hg19_multianno_dbremoved_removed_final_index_inheritence_import_classify.txt
16-0002_File-B_variant_strandbias_readcount.vcf.hg19_multianno_dbremoved_removed_final_index_inheritence_import_classify.txt
16-0005_File-C_variant_strandbias_readcount.vcf.hg19_multianno_dbremoved_removed_final_index_inheritence_import_classify.txt

desired output
Code:
16-0000_File-A_hg19multianno.txt
16-0002_File-B_hg19multianno.txt
16-0005_File-C_hg19multianno.txt

Code:
rename 's/(.*?_[^_]+).*/${1}_hg19multianno.txt/g' /home/cmccabe/Desktop/test/vcf/overall/annovar/*_classify.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extracting text and reusing the text to rename file

Hi, I have some ps files where I want to ectract/copy a certain number from and use that number to rename the ps file. eg: 'file.ps' contains following text: 14 (09 01 932688 0)t the text can be variable, the only fixed element is the '14 ('. The problem is that the fixed element can appear... (7 Replies)
Discussion started by: JohnDS
7 Replies

2. Shell Programming and Scripting

How can i break a text file into parts that occur between a specific pattern

How can i break a text file into parts that occur between a specific pattern? I have text file having various xml many tags like which starts with the tag "<?xml version="1.0" encoding="utf-8"?>" . I have to break the whole file into several xmls by looking for the above pattern. All the... (9 Replies)
Discussion started by: abhinav192
9 Replies

3. Shell Programming and Scripting

extract specific string and rename file

Hi all, I am working on a small prog.. i have a file.txt which contains random data... K LINES V4 ADD CODE `COMPANY` ADD CODE `DISTRIBUTOR` SEQ NAME^K LINES V5 SEQ NAME^K LINES V6 ADD `PACK-LDATE` SEQ NAME^K^KCOMMAND END^KHEADINFO... (1 Reply)
Discussion started by: mukeshguliao
1 Replies

4. Shell Programming and Scripting

Help with remove last text of a file that have specific pattern

Input file matrix-remodelling_associated_8_ aurora_interacting_1_ L20 von_factor_A_domain_1 ATP_containing_3B_ . . Output file matrix-remodelling_associated_8 aurora_interacting_1 L20 von_factor_A_domain_1 ATP_containing_3B . . (3 Replies)
Discussion started by: perl_beginner
3 Replies

5. UNIX for Dummies Questions & Answers

look for file size greater than "0" of specific pattern and move those to another directory

Hi , i have some files of specific pattern ...i need to look for files which are having size greater than zero and move those files to another directory.. Ex... abc_0702, abc_0709, abc_782 abc_1234 ...etc need to find out which is having the size >0 and move those to target directory..... (7 Replies)
Discussion started by: dssyadav
7 Replies

6. Shell Programming and Scripting

Rename the file with specific pattern

Hello I am making a script where I need to rename the files but with different names.The file name could be change according to the product I made a logic but that is not working properly arr=$(echo a@b@c | tr "@" "\n") echo $arr output is a b c arry=$(echo d@e@f | tr "@" "\n") ... (4 Replies)
Discussion started by: anuragpgtgerman
4 Replies

7. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

8. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. UNIX for Beginners Questions & Answers

How to zip csv files having specific pattern in a directory using UNIX shell script?

I have files in a Linux directory . Some of the file is listed below -rw-rw-r--. 1 roots roots 0 Dec 23 02:17 zzz_123_00000_A_1.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_121_00000_A_2.csv -rw-rw-r--. 1 roots roots 0 Dec 23 02:18 zzz_124_00000_A_3.csv drwxrwxr-x. 2 roots roots 6 Dec 23... (4 Replies)
Discussion started by: Balraj
4 Replies

10. Shell Programming and Scripting

Match all lines in file where specific text pattern is less than

In the below file I am trying to grep or similar, all lines where only AF= is less than 0.4.. Thank you :). grep grep "AF=" ,+ .4 file file 12 112036782 . T C 34.0248 PASS ... (3 Replies)
Discussion started by: cmccabe
3 Replies
pycocuma(1)							    Addressbook 						       pycocuma(1)

NAME
pycocuma - Pythonic Contact and Customer Management SYNTAX
pycocuma [options] [connection-string] DESCRIPTION
PyCoCuMa (Pythonic Contact and Customer Management) provides a personal information system for addresses, telephone numbers and other data associated with personal contacts (also supports photographic pictures). PyCoCuMa is purely written in Python with a Tk graphical interface. PyCoCuMa is based on an XML-RPC client-server architecture. The server stores its data in compatible vCard (ver. 3.0) files (*.vcf) which can be read by all modern address programs (Evolution, KAddressbook, Outlook, GnomeCard, etc). This manpage documents the PyCoCuMa client (which can also run standalone). OPTIONS
connection-string addressbook filename / server url -h --help show help -c --config location of configuration file (default: ~/.pycocuma) --noconf do not save configuration / preferences -t --type connection type: xmlrpc or file (default: file) --finder open QuickFinder --import import from file/stdin (-) (e.g. vcard:/tmp/John.vcf) --export export to file or stdout (e.g. latex:-) EXAMPLES
pycocuma --type=xmlrpc http://localhost:8810 pycocuma --config=/tmp/pycocumatest.conf --type=file ./addressbook.vcf AUTHORS
PyCoCuMa was written by Henning Jacobs. This manpage was written by Christoph Berg for the Debian GNU/Linux distribution (but may be used by others). SEE ALSO
PyCoCuMa home page http://www.srcco.de/pycocuma/ pycocuma-server(1) Debian 0.4.5-5 pycocuma(1)
All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy