Sponsored Content
Top Forums Shell Programming and Scripting Bash to add portion of text to files in directory using numerical match Post 302995161 by Don Cragun on Sunday 2nd of April 2017 11:29:58 AM
Old 04-02-2017
Take a look at your code again. There is no mv command in your code; only an echo command. If the echo shows that your script is correctly determining what arguments should be passed to mv, what happens if you change the line:
Code:
[ -n "$oldfilename" ] && echo mv \"$oldfilename\" \"${id}_${newname}_${oldfilename#*_}\";

in your code to:
Code:
[ -n "$oldfilename" ] && mv "$oldfilename" "${id}_${newname}_${oldfilename#*_}";

(i.e., remove the echo and the backslashes)?
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match portion of the filename

hi, I have a script which accept filename and process them, however, one of the file needs 'special' handling so I need to identify it, say the filename contains the word "STOCK" (i.e. NEWYORKSTOCKLIST20060627.txt), I want to check if the filename contains the word "STOCK", how can I do that?... (1 Reply)
Discussion started by: mpang_
1 Replies

2. Shell Programming and Scripting

Counting files in a directory that match a pattern

I have 20 files in a direcotry like BARE01_DLY_MKT_YYYYMMDD. The MKT differes for all these files but the remaining syntax remains the same for a particular day. If I am checking for today I need to make sure that there are 20 files that start with BARE01_DLY_MKT_20060720. How can I write a... (31 Replies)
Discussion started by: dsravan
31 Replies

3. Programming

Fuzzy Match Logic for Numerical Values

I have searched the internet (including these forums) and perhaps I'm not using the right wording. What I'm looking for is a function (preferably C) that analyzes the similitude of two numerical or near-numerical values, and returns either a true/false (match/nomatch) or a return code that... (4 Replies)
Discussion started by: marcus121
4 Replies

4. Shell Programming and Scripting

search a regular expression and match in two (or more files) using bash

Dear all, I have a specific problem that I don't quite understand how to solve. I have two files, both of the same format: XXXXXX_FIND1 bla bla bla bla bla bla bla bla bla bla bla bla ======== (return) XXXXXX_FIND2 bla bla bla bla bla bla (10 Replies)
Discussion started by: TheTransporter
10 Replies

5. Shell Programming and Scripting

Perl: batch replace a portion of text in files

Hi all, What I would like to achieve is to batch change the code below in every pdf in a given directory (each pdf is uncompressed so that can be easily edited). An example of the javascript code: if (this.hostContainer) { try { this.hostContainer.postMessage(pp_216', 15259]);... (3 Replies)
Discussion started by: menteith
3 Replies

6. Shell Programming and Scripting

Text match in two files

Trying to match the text from file1 to file2 and print what matches in a new file (match.txt) and what does not in another (missing.txt). awk -F'|' 'NR==FNR{c++;next};c > 0' flugent.txt IDT.txt > match.txt Thank you :). (8 Replies)
Discussion started by: cmccabe
8 Replies

7. Shell Programming and Scripting

Display match or no match and write a text file to a directory

The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
Discussion started by: cmccabe
4 Replies

8. Shell Programming and Scripting

Match and store numerical prefix to update files

In the bash below the unique headers of each vcf.gz are stored in a text file with the same name. That is if 16-0000-file.vcf.gz was used the header text file would be 16-0000-file_header.txt. There can be multiple vcf.gz in a directory, usually 3, that I need to fix the header in each file before... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

Bash to move specific files to directory based on match to file

I am trying to mv each of the .vcf files in the variants folder to the folder in /home/cmccabe/f2 that the .vcf id is found in file. $2 in file will always have the id of a .vcf in the variants folder. The line in blue staring with R_2019 in file up to the -v5.6 will always be an exact match to a... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Bash to rename portion of file using match to another

In the portion of bash below I am using rename to match the $id variable to $file and when a match (there will alwsys be one) is found then the $id is removed from each bam and bam.bai in $file and _test is added to thee file name before the extension. Each of the variables is set correctly but... (3 Replies)
Discussion started by: cmccabe
3 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 02:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy