Replacing the part of file name?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing the part of file name?
# 8  
Old 10-09-2008
oldtimestamp="20080227"
newtimestamp="20070909"
for file in `ls $log_path`
do
prefix=${file%%"$oldtimestamp"}
lastfix=${file##"$oldtimestamp"}
/usr/bin/mv "$file" "${prefix}${newtimestamp}${lastfix}" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
# add log here
fi
done

Last edited by a2156z; 10-09-2008 at 05:54 AM..
a2156z
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing part of a delimited string

Hello, I have some tab delimited text data that I am processing. The second column looks like, NAME;pyrimidine-2,4-diol;cpd;2;line;37 I need to clean this up to just the name, pyrimidine-2,4-diol All lines have the same format, NAME;text;cpd;int;line;int followed by tab I have tried... (6 Replies)
Discussion started by: LMHmedchem
6 Replies

2. UNIX for Dummies Questions & Answers

Replacing part of filename

Hi guys! I have quite a lot of files like all_10001_ct1212307460308.alf* and I want to get rid of the first number for all at once like: all_ct1212307460308.alf* How can I do this in the shell? (12 Replies)
Discussion started by: TimmyTiz
12 Replies

3. Shell Programming and Scripting

Renaming Filenames by replacing a part

Hi, I have little experience on Shell scripts, I searched the forum but couldn't make out what I want. I want to rename a set of files to a new file name a_b_20100101 c_d_20100101 ....................... ...................... I want to rename the files to a_b_20140101... (5 Replies)
Discussion started by: JaisonJ
5 Replies

4. Shell Programming and Scripting

Replacing part of the sentence using echo and sed

Hi, Iam using ksh and trying to execute the following syntax to replace one word of the sentence with a new word. But somehow sed is not able to replace the old value with new value. Please let me know where Iam going wrong. Sample Code : --> export line="VORTEX,abcdef" export... (3 Replies)
Discussion started by: ajithab
3 Replies

5. Shell Programming and Scripting

Awk: Need help replacing a specific column in a file by part of a column in another file

Hi, I have two input files as File1 : ABC:client1:project1 XYZ:client2-aa:project2 DEF:client4:proj File2 : client1:W-170:xx client2-aa:WT-04:yy client4:L-005A:zz Also, array of valid values can be hardcoded like Output : ABC:W:project1 XYZ:WT:project2 (1 Reply)
Discussion started by: aa2601
1 Replies

6. Shell Programming and Scripting

Replacing part of XML code inside comment tags

Hello! I'd like to modify custom values in a XML config file between comment tags using bash script. <feature> <keyboardshortcut>C-m</keyboardshortcut> <option1>disabled</option2> <option2>enabled</option2> </feature> <!-- bash script features START --> <feature> ... (2 Replies)
Discussion started by: prism1
2 Replies

7. Shell Programming and Scripting

Replacing part of a pattern in sed

Hi I have a piece of xml that has a pattern like this <int>159</int><int>30</int> I want to find this pattern but only substitute the second part of the pattern to {rid1}. Is that possible in sed ? Thanks. ---------- Post updated at 12:10 PM ---------- Previous update was at 12:01 PM... (11 Replies)
Discussion started by: vnn
11 Replies

8. Shell Programming and Scripting

Replacing some part of file

Hello, I have two files, consider that as file1 and file2. Here file1 is the master file. file1 will contain data like GS*RA*071000013*102562451P*091130*0520*334052023*X*003050 ST*820*334052023 BPR*C*509.77*C*ACH*CTX*01*071000013*DA*5529085*9000002008**01*071000013*DA*5529085*091130... (8 Replies)
Discussion started by: atlantis
8 Replies

9. UNIX for Dummies Questions & Answers

Replacing part of a text file with user input.

Ok, I am brand new to UNIX and I am trying to learn a cross between basic script and database use. I had got some ideas off the net on simple ideas for learning UNIX. I am working on creating a simple phone book program that allows myself to enter our employees from work into a phone book text... (0 Replies)
Discussion started by: georgefurbee
0 Replies

10. Shell Programming and Scripting

Need help regarding replacing a part of string

Hi all suppose i have a string "abacus sabre", i need to replace occurences 'ab' with 'cd' and i need to store this result into same string and i need to return this result from script to the calling function, where as the string is passed from calling function. i tried like this ... (1 Reply)
Discussion started by: veerapureddy
1 Replies
Login or Register to Ask a Question
SDPA(1) 						      General Commands Manual							   SDPA(1)

NAME
SDPA - High-performance software package for SemiDefinite Programs SYNOPSIS
sdpa DataFile OutputFile [InitialPtFile] [-pt parameters] [-dimacs] [-numThreads numThreads] sdpa [options] files... sdpa --version DESCRIPTION
sdpa - "SDPA (SemiDefinite Programming Algorithm)" is one of the most efficient and stable software packages for solving SDPs based on the primal-dual interior-point method. SDP (SemiDefinite Program) is used for financial engineering, machine learning, control theory, sensor network problem, quantum chemistry, quantum information, combinatorial optimizaiton, polynomial optimization, and so on. Futher information on SDP and SDPA can be found at http://sdpa.sourceforge.net/ OPTIONS
---- option type 1 ---- sdpa DataFile OutputFile [InitialPtFile] [-pt parameters] [-dimacs] [-numThreads numThreads] parameters = 0 default, 1 fast (unstable), 2 slow (stable) example1-1: sdpa example1.dat example1.result example1-2: sdpa example1.dat-s example1.result example1-3: sdpa example1.dat example1.result example1.ini example1-4: sdpa example1.dat example1.result -pt 2 example1-5: sdpa example1.dat example1.result -dimacs example1-6: sdpa example1.dat example1.result -numThreads 4 ---- option type 2 ---- sdpa [option filename]+ -dd : data dense :: -ds : data sparse -id : init dense :: -is : init sparse -o : output :: -p : parameter -pt : parameters , 0 default, 1 fast (unstable) 2 slow (stable) example2-1: sdpa -o example1.result -dd example1.dat example2-2: sdpa -ds example1.dat-s -o example1.result -p param.sdpa example2-3: sdpa -ds example1.dat-s -o example1.result -pt 2 example2-4: sdpa -ds example1.dat-s -o example1.result -dimacs example2-5: sdpa -ds example1.dat-s -o example1.result -numThreads 4 ---- option type 3 ---- sdpa --version to print out version and exit. PARAMETER_FILE is decided by the following priority 1: The file assigned by '-p' option of 'option type 2'. For 'option type1', this is skipped. 2: ./param.sdpa For 'option type2', this is skipped. 3: /usr/share/sdpa/param.sdpa 4: Default parameter -dimacs printout dimacs information incurring additional computation cost -numThreads number of pthreads for internal computation AUTHOR
SDPA was written by SDPA Project <sdpa-developers@lists.sourceforge.net>. This manual page was written by Makoto Yamashita <Makoto.Yamashita@is.titech.ac.jp>. July 28, 2011 SDPA(1)