Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
added 2 characters in body
Source Link

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. The resulting filenames will have prefixes that are based on column 1 like this:

GBH03987.sorted_dup.bam

GBH05430.sorted_dup.bam

GBH07651.sorted_dup.bam What

What is the easiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. The resulting filenames will have prefixes that are based on column 1 like this:

GBH03987.sorted_dup.bam

GBH05430.sorted_dup.bam

GBH07651.sorted_dup.bam What is the easiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. The resulting filenames will have prefixes that are based on column 1 like this:

GBH03987.sorted_dup.bam

GBH05430.sorted_dup.bam

GBH07651.sorted_dup.bam

What is the easiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

Added examples of the final file name
Source Link

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. WhatThe resulting filenames will have prefixes that are based on column 1 like this:

GBH03987.sorted_dup.bam

GBH05430.sorted_dup.bam

GBH07651.sorted_dup.bam What is Unixeasiestthe easiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. What is Unixeasiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

I have hundreds of files in a directory with the same suffix and unique alphanumeric prefixes like this:

ABC01234.sorted_dup.bam

ABC04271.sorted_dup.bam

ABC09287.sorted_dup.bam

I have a file with new unique alphanumeric prefixes in one column spefic to each of the original prefixes like this:

GBH03987 ABC01234

GBH05430 ABC04271

GBH07651 ABC09287

I would like to replace the original prefixes with the correct prefixes from the file i.e. replace the prefixes in the filenames in the directory with the prefixes in column 1. The resulting filenames will have prefixes that are based on column 1 like this:

GBH03987.sorted_dup.bam

GBH05430.sorted_dup.bam

GBH07651.sorted_dup.bam What is the easiest solution for someone new to unix? Preferably an awk or sed solution would be greatly appreciated.

added 40 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88
Loading
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Loading
Source Link
Loading