Sponsored Content
Top Forums Shell Programming and Scripting need shell script for moving file one by one Post 302222541 by manojkarthi on Thursday 7th of August 2008 02:32:16 AM
Old 08-07-2008
i have tried but it showing *.txt not found why its showing ..like this ...
In the directory ...five txt files are there

In "manoj.sh" 16 lines, 432 characters
SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$`;
do
mv $i /amddev/app01/manoj/new/scripts/new/
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
echo Manoj successfully..1
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done

~
~
"manoj.sh" 16 lines, 432 characters
[5] + Stopped vi manoj.sh
mds@ttl03ap:/amddev/app01/manoj/new/scripts>sh manoj.sh
$/amddev/app01/manoj/new/scripts/old/*.txt not found
mds@ttl03ap:/amddev/app01/manoj/new/scripts>cd ../old
mds@ttl03ap:/amddev/app01/manoj/new/old>cd /amddev/app01/manoj/new/scripts/old/
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>ls
TTLNotes.txt a man.txt
TTLNoteslast.txt b srnoteska.txt
UPDATEFILEPRECHECKFMSUPE060808.txt c
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>


"manoj.sh" 16 lines, 432 characters
SD="$/amddev/app01/manoj/new/scripts/old"
TD="$/amddev/app01/manoj/new/scripts/new"
EXT="$*.txt"
for i in `ls -F "$SD"/*"$EXT"|grep -v /$`;
do
mv $i /amddev/app01/manoj/new/scripts/new/
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
echo Manoj successfully..1
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done

~
~

"manoj.sh" 16 lines, 432 characters
[5] + Stopped vi manoj.sh
mds@ttl03ap:/amddev/app01/manoj/new/scripts>sh manoj.sh
$/amddev/app01/manoj/new/scripts/old/*.txt not found

mds@ttl03ap:/amddev/app01/manoj/new/old>cd /amddev/app01/manoj/new/scripts/old/
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>ls
TTLNotes.txt a man.txt
TTLNoteslast.txt b srnoteska.txt
UPDATEFILEPRECHECKFMSUPE060808.txt c
mds@ttl03ap:/amddev/app01/manoj/new/scripts/old>

Last edited by manojkarthi; 08-07-2008 at 03:47 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies

2. Shell Programming and Scripting

Help with shell script: moving end of line character

Hello. I have a file (old.txt) that I need to copy into another file (new.txt). Each line on old.txt ends with CR/LF but the position of CR/LF varies from one record to another. I need to copy each line of record to new.txt and move CR/LF in pos 165. Can I use awk to achieve this? How?... (8 Replies)
Discussion started by: udelalv
8 Replies

3. Shell Programming and Scripting

Need help with shell script for moving/deleting/renaming files

Hi. I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next. Here's an example: /var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Discussion started by: aflower
4 Replies

4. Shell Programming and Scripting

Shell Script for moving 3 days old file to Archive Folder

Hi Experts, I have a "Source" folder which may contain some files. I need a shell script which should move all files which are older than 3 days to "Archive" folder. Thanks in Advance... (4 Replies)
Discussion started by: phani333
4 Replies

5. UNIX for Dummies Questions & Answers

File Moving Script

I want to make a script that moves all files with a keyword on it to another folder. and lets me know how many files it moved with that keyword. Im a total newbie with scripting so a little help would be much appreciated. (3 Replies)
Discussion started by: marchina
3 Replies

6. Shell Programming and Scripting

Moving log files based on month - help with ksh shell script

Hello, I'm trying to move the log files from the parent directory to respective monthly folder and I would be running this script on a weekly basis through cron. I'm new to this scripting and here is what i could come up and it runs without really doing anything. I even tried placing echo... (2 Replies)
Discussion started by: jusblues
2 Replies

7. Ubuntu

Shell Scripting , Moving Old file to specific folder

There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/logyou need to find out all the log files of last 1 month and move them into $HOME/logs/lastmonth/ this should be implemented with reference of file name. ---------- Post updated at 12:30 PM ----------... (3 Replies)
Discussion started by: shajoftaj
3 Replies

8. Homework & Coursework Questions

Shell Scripting , Moving Old file to specific folder

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/log you need to find out all... (4 Replies)
Discussion started by: shajoftaj
4 Replies

9. Shell Programming and Scripting

Shell Script for renaming and moving Files - Easy?

Hey guys, ive been working on this for about 2hrs now - without any solution. At first I need to say I dont have skills in linux bash scripting, but I tried to use some codesnippets and manuals from google. What I want to do: I have different folders including 2 different filestypes with... (15 Replies)
Discussion started by: peter1337
15 Replies

10. Shell Programming and Scripting

Beginner need help how file moving script could look like

Hi there, I am an absolut beginner in scripting. I am using Ubuntu Linux 18.04 LTS: I just need some hints/suggestions how a script could look like doing the following stuff: assuming I am in directory "base_directory" like xyz@mypc:~/base_directory$ within the "base_directory there... (1 Reply)
Discussion started by: dut42
1 Replies
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 06:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy