Unix file pattern check and replacement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix file pattern check and replacement
# 8  
Old 10-08-2012
For existing entries (and apologies not the slickest production solution):
Code:
ls -1 /tmp/Access_file_Record*.* | while read line
do
  IFS=.
  set $line
  IFS=" "
  if [ $2 = "txt" ]
  then
    echo "mv $line $1"
    mv $line $1
  else
    echo "mv $line $1$2"
    mv $line $1$2
  fi
done


Last edited by Franklin52; 10-09-2012 at 03:10 AM.. Reason: Please use code tags for data and code samples
# 9  
Old 12-11-2012
you may also want to look at this thread problem with sed * wildcard to have more clarity....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern Matching and replacement

Hello Everybody, I need a help in the below pattern matching and replacement issue I have a file : emp.txt 21356 suresh 12/12/2012 23511 ramesh 11/06/2011 31456 biswajit 09/08/2013 53134 archan 06/02/2009 first field:- employee id, 2nd field is name and third field is date of joining ... (10 Replies)
Discussion started by: shellscripting
10 Replies

2. Shell Programming and Scripting

Check for Pattern if exists write to file

Hi ! All I just want to search and write to new file if pattern is found in text file following are my text files by which I want to search Month and last column number my text file1 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25... (3 Replies)
Discussion started by: nex_asp
3 Replies

3. Shell Programming and Scripting

Check the file if the search pattern is there or not.

I want to check the files if the below pattern is there or not. I have to scan thousands of files. It should start search with "Group" (Case insensitive) and followed by first semicolon ";" . In between these two there should be "partition"(case insensitive). File1.txt a) update... (1 Reply)
Discussion started by: smolakal
1 Replies

4. Shell Programming and Scripting

String replacement when particular pattern matches in a file

I have a file file123.xml which looks like this xmlEntry="username"="josh" <property="never_back_down"> phone="<178652>" apn=property:address="wonderland" xmlEntry="username"="jessica" <property="never_back_down"> phone="<178653>" apn=property:address="wonderland"... (5 Replies)
Discussion started by: poga
5 Replies

5. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

6. Shell Programming and Scripting

check if file exists with pattern matching

Hello friends, I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed. My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc.. I... (6 Replies)
Discussion started by: sreenu.shell
6 Replies

7. UNIX for Dummies Questions & Answers

awk pattern replacement

Hi I'm a newbie in unix and I'm having trouble in creating a script. I want to search for a pattern '_good' and insert new lines that contains '_bad', '_med', '_fail' while also ensure that the line contains _good is removed here some of the data UPDATE SCHOOL SET GRADE =... (1 Reply)
Discussion started by: sexyTrojan
1 Replies

8. Linux

matching pattern and replacement

Hi I am trying to look for a view name in create view statement and then replace this view name with VW_ in grants line in my ddl file . cat dim_provider.sql | grep -i "create view" | while read f1 f2 f3 f4 f5 f6 f7 f8 f9 do new_vw=` echo "$f3" | cut -d "." -f2... (32 Replies)
Discussion started by: capri_drm
32 Replies

9. UNIX for Dummies Questions & Answers

Pattern Replacement

There is a requirement that i need to replaced a pattern by another pattern in all the files in my entire file system. there are 1000s of file in the system. let the pattern is "calcuta". i have to replace this pattern by "kolkata" in all those files which contain "calcuta". I am only able to... (12 Replies)
Discussion started by: palash2k
12 Replies

10. Shell Programming and Scripting

how to check for pattern in other file

i hav file1 with contents: welcome this is first file file name is file 1 last line of the file now i want to check if the second line has sentence "this is first file" through "if" statement from another file ... is it possible if so how!!! (6 Replies)
Discussion started by: suri
6 Replies
Login or Register to Ask a Question