Changing txt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing txt
# 1  
Old 05-06-2009
(find . -type f | while read i) Deleting Dates

Hi all,

I currently use this code to delete text from file names when they are dropped in a folder.

Code:
find . -type f | while read i;do [ "$i" != "${i//2009abc/}" ] && mv "$i" "${i//2009abc/}" ;done

I have four versions of the code that delete the unwanted text if it has 2006, 2007, 2008 and 2009 with other standard text in it in four different folders.

Is there a way that I could re-write the code so that for argument sake delete any date from say 1990 to 2009 with and any date before that leave it in.

For example;

HTML Code:
Input: name of file 2009 abc.mov
Output: name of file.mov
HTML Code:
Input: name of file 2008 abc.mov
Output: name of file.mov
HTML Code:
Input: name of file 2007 abc.mov
Output: name of file.mov
HTML Code:
Input: name of file 2006 abc.mov
Output: name of file.mov
HTML Code:
Input: name of file 1987 abc.mov
Output: name of file 1987.mov
Is this possible?

Thanks in advance Smilie

Last edited by Monkey Dean; 05-06-2009 at 06:33 AM..
# 2  
Old 05-06-2009
Can anyone help me on this one?
# 3  
Old 05-06-2009
Please be more patient, it's not allowed to bump up questions, read the rules.
# 4  
Old 05-06-2009
Hi Monkey_dean,

Is it the file names which will have the dates like this ?

1987.abc.mov
2008.abc.mov
2009.abc.mov

or the content of the file will hav these data ?..

In the first case ... Is this file names are havng uniq syntax ( i mean date.abc.mov ) ?..always

or any where in the file name date hav to delete ?..
# 5  
Old 05-06-2009
I think the best way to describe this and simplify the matter would be to say -

Can I edit this script:

Code:
find . -type f | while read i;do [ "$i" != "${i//abc/}" ] && mv "$i" "${i//abc/}" ;done

so that it will not only take out abc from the filename but also take out any numbers that are in the filename.

Sorry if I did not explain myself better.


Regards Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in

Hi dears i have text file like this: INPUT.txt 001_1_173 j nuh ]az 001_1_174 j ]esma. nuh ]/.xori . . . and have another text like this TABLE.txt j j nuh word1... (6 Replies)
Discussion started by: alii
6 Replies

2. UNIX for Dummies Questions & Answers

Vi. changing txt into table

just discover this thread. It sounds perfect for me because I am following an online course on command line tools and some instruction ... seems not be replicable on my Terminal Here is an example on a txt file with n rows each containing 3 word separated by a space. a b c d e f .... ... (5 Replies)
Discussion started by: mrMe
5 Replies

3. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

4. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

5. OS X (Apple)

Changing txt files to pure UTF-8

I have two Macs running 10.7.5. We download .txt files from remote site to these local Macs using 'rsync -e ssh -avz...'. The files on Mac1 are in the required format of pure UTF-8. The files on Mac2 are in UTF-8 (no BOM) which is wrong format for us; these formats are indicated using BBEdit.... (1 Reply)
Discussion started by: sovdia
1 Replies

6. Shell Programming and Scripting

Delete file2.txt from file1.txt using scripting

Hi, I`m a total newbie, well my requirement is that i have 2 files I want to identify which countries i do not currently have in db.. how can i use the grep or another command to find this file .. i want to match all-countries.txt with countries-in-db.txt so the output is equal to... (11 Replies)
Discussion started by: beanbaby
11 Replies

7. Shell Programming and Scripting

Changing Line in Txt File

So I have a python program that I run, which runs accordingly to options I have listed in a text file (ie user_prefs). Now there are many options listed in this user_prefs.txt, but the one of most interest to me is that of the file path of the time series. I have over a hundred of these time... (8 Replies)
Discussion started by: Jimmyd24
8 Replies

8. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

9. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

10. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies
Login or Register to Ask a Question