Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to rename the files given below and move to some other path


expected Result


only I need to remove the timestamp attached every time with the filenames,and move it to other directory in AIX please help me to write the script.I am new to Unix as I am able to rename single single files but not all,and moving to other path also had issue.

For your reference I had tried.

file1=`echo 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 | awk -F "." '{for(i=1;i<NF;i++) if ($i!= 1) f=f?f FS $i:$i;print f;f=""}'`
echo $file1
share|improve this question
do you have rename by larry wall – richard Jul 18 '14 at 16:29
I didnt use "rename" option Not sure if it will work for multiple files,and then move to other path – Ankit Jul 18 '14 at 16:39
The rename command I am writing about can do both at same time. (all rename/mv tools I have used on Unix can rename and move at same time). Beware the rename you have may not be the same rename, this one is written in purl written by Robin Barker and Larry Wall. – richard Jul 18 '14 at 16:48

Awk isn't going to make your life easier. You can use the suffix removal syntax: ${x%.*} is the value of the variable x with the shortest suffix of the form .* removed.

for x in *.txt.*.*; do
  mv "$x" "/other/directory/${x%.*}"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.