[SOLVED] moving multiple files? mv


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [SOLVED] moving multiple files? mv
# 8  
Old 09-17-2012
Code:
 
#!/bin/ksh
for i in *.new
do
    mv "$i" "${i%*.new}"
done

# 9  
Old 09-17-2012
Quote:
Originally Posted by msabhi
Code:
 ls *.new | sed 's/\(.*\).new/mv & \1/' | sh

I believe you have only those files that needs to be moved in the directory where you are going to execute above
Thanks msabhi...prior to this example I was assuming that it is not possible to use shell commands inside sed.
Could you please tell about some shell commands that could be used inside sed ?
# 10  
Old 09-17-2012
Quote:
Originally Posted by aashish.sharma8
Thanks msabhi...prior to this example I was assuming that it is not possible to use shell commands inside sed.
He's not.

Leave the | sh off the end to see what it does.
# 11  
Old 09-17-2012
Quote:
Originally Posted by Corona688
He's not.

Leave the | sh off the end to see what it does.
Yes as corona pointed out, am not using any shell command inside sed there...i am just executing whats thrown out by sed...
My knowledge is limited on usage of shell commands inside sed..but from what i remember from my experience, we can use some commands like echo inside sed like below
Code:
sed "1i `echo FIRST`" tmp_file

But you can't use cat command inside sed or i have failed trying to use cat command inside sed..
This User Gave Thanks to msabhi For This Post:
# 12  
Old 09-17-2012
Quote:
Originally Posted by Corona688
He's not.

Leave the | sh off the end to see what it does.
Ah..Great...
Thanks Corona...learnt something new today !!
# 13  
Old 09-17-2012
thank u all !!!

all these commands were helpful and I used thell
Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Moving multiple datestamped files (Linux)

Hello all, I'm writing a script that will allow me to move files into a sub-directory for archiving. These files, specifically, are output files that result at the end of a process. The issue I'm having is that while moving files from one place to another is relatively an easy task, grabbing... (2 Replies)
Discussion started by: galileo1
2 Replies

2. Shell Programming and Scripting

Moving and renaming multiple files in a directory

Hi. I am trying to automate the movement and renaming of a number of files in a directory. I am using the 'mv' command as I do not have access to 'rename'. I have the following scripted FILES=$(ls /transfer/move/sys/mail/20130123/) if ; then for i in ${FILES} ; do mv... (4 Replies)
Discussion started by: jimbojames
4 Replies

3. UNIX for Advanced & Expert Users

Moving multiple files based on the pattern

I want to search for a particular file name patterns and move them to a specific folder, is it possible to do it with awk or sed? (1 Reply)
Discussion started by: rudoraj
1 Replies

4. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

5. UNIX for Dummies Questions & Answers

Moving files out of multiple directories and renaming them in numerical order

Hi, I have 500 directories each with multiple data files inside them. The names are sort of random. For example, one directory has files named e_1.dat, e_5.dat, e_8.dat, etc. I need to move the files to a single directory and rename them all in numerical order, from 1.dat to 1000(or some... (1 Reply)
Discussion started by: renthead720
1 Replies

6. Shell Programming and Scripting

using mv command for moving multiple files in a folder

Hi, I have a requirement where I need to move Bunch of folders containing multiple files to another archive location. i want to use mv command .I am thinking when we use mv command to move directory does it create directory 1st and then move all the files ? e.g source... (4 Replies)
Discussion started by: rkmbcbs
4 Replies

7. Shell Programming and Scripting

moving multiple folders/files in subversion using bash script

Hi, I'm new here an dlearning a lot from this forum. i didnt find any solution for this in the forum. I have already checked in folders in subversion named HTT01,... HTT21.. and have files in each folder like below: HTT01/HTT01_00000.hex HTT01/HTT01_00000_fb_result.hex... (2 Replies)
Discussion started by: ravishan21
2 Replies

8. Shell Programming and Scripting

Moving multiple files and renaming them on the fly

Hi All, Being new to scripting I am facing a new situation. We have an application that generates a file lets say dumpfile for each user under the users home directory when they execute the application. This is quite a huge file and imagine having that for over 40 users on a daily basis. The... (1 Reply)
Discussion started by: daemongk
1 Replies

9. Shell Programming and Scripting

moving and renaming multiple files

Greetings, I know i can use the mv command to move and rename one file. How can I do this with multiple files? example pic01.bmp to pic0001.bmp how can i perform this function on an entire directory of sequential files and keep them in sequence? Hints, suggestions are most welcome:) ... (1 Reply)
Discussion started by: rocinante
1 Replies

10. UNIX for Advanced & Expert Users

moving multiple files --recursively using BSD

i am using a FreeBSD remote account and I have directory that holds a number of other directories most of which posses *.tgz *.tar.bz2 *.gz files... on a linux system i would use a find format such as this to locate and mv *.tgz and *.tar.bz2 files find ./dir -type f -iname "*.t*" -print |... (3 Replies)
Discussion started by: moxxx68
3 Replies
Login or Register to Ask a Question