Sponsored Content
Top Forums Shell Programming and Scripting Renaming file and check for the renamed file existence Post 302773545 by Priya Amaresh on Thursday 28th of February 2013 07:23:26 AM
Old 02-28-2013
Renaming file and check for the renamed file existence

Hi
Am trying to move a file from one name to another
When I do "ls" to check for the moved filename
I can see the file but when I try the same with a script am unable..
I think am doing some pretty silly error.. please help..

Code:
toMove=`ls | grep -E "partition.[0-9]+"`
mv $toMove partition.[0-9]_org
if [ $? -eq 0 ]; then
        echo "Success.. The value of $toMove"
else
        echo "FAIL"
fi

#Checking for file has transferred..
toFind=`ls | grep -E "partition.[0-9]_org"`
if [ $? -eq 0 ]; then
        echo "Success.. The value of $toFind "
else
        echo "FAIL"
fi

Here the value toFind returns a FAIL state..Smilie

Last edited by Priya Amaresh; 02-28-2013 at 08:42 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Csh to check for existence of file

Hi, I would like to check the existence of files (doesn;t matter the number of files) in a directory. My file is named in the following manner (always ending with " myfile "). Can anybody give me some guidance? EG: abc1_myfile sdfr_myfile sffgd_myfile and so on ...... My... (9 Replies)
Discussion started by: Raynon
9 Replies

2. AIX

how to check the existence of a file using korn shell?

we have tranferred an ear from local server to remote server using ftp.consider, we have an ear file named a.ear in remote server,again if we transfer the same file named a.ear from local server to remote server.we need the kshell to check the existence of the ear file in remote server,and if the... (3 Replies)
Discussion started by: karthikprasathk
3 Replies

3. AIX

check for file existence

Hello I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script. My script basically does for File in `ls -t $DIRECTORY | tail -1`; if there is no file the DIRECTORY then the script is simply exiting with out... (2 Replies)
Discussion started by: dsdev_123
2 Replies

4. AIX

Check for File Existence

I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
Discussion started by: dsdev_123
4 Replies

5. Shell Programming and Scripting

How to check for file existence?

i want to check if the file is in the directory or not, and also it should be handle error conditions, like missing files and report the error and exit. i did something like this: file ="hello" if !test -e "${file}" then echo "No such files exist!" exit 1 else do something....... fi ... (1 Reply)
Discussion started by: mingming88
1 Replies

6. Shell Programming and Scripting

Check for file existence using wildcards

I am using the following command to check for files on a Unix (Solaris 9) and on Linux: if (-r *.) then echo " las file found" else echo " no las file found" endif If no las file is present, the "no las file found" message is displayed. If a las file is present, however, I get... (9 Replies)
Discussion started by: phudgens
9 Replies

7. Shell Programming and Scripting

command to check existence of file name which has regex

Hi All. Pls help me with the command to check existence of files (I'll mention name of the file as regex) and proceed with my further processing if atleast one of them exists in detail, I've a dir /tmp/TURP, which may or may not have files named with "exter*.txt" I need to check and... (2 Replies)
Discussion started by: skpvalvekar
2 Replies

8. UNIX for Dummies Questions & Answers

To check for existence of a file

I need to check for the existence of a file *.log in a specific directory using a perl script. Presently am not in that particular directory. So i am using chdir ("/path/to/my/file) And then i am using the -e in an if statement to check if it exists. if (-e $File) {......} $File contains the... (1 Reply)
Discussion started by: manutd
1 Replies

9. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

10. Shell Programming and Scripting

File existence check

hi i wanted to check if the file exist or not(multiple files) DIRE=/home/V478 if ; then echo "file present" else echo "file not present" fi But i am getting the error as : [: unexpected operator/operand (3 Replies)
Discussion started by: ATWC
3 Replies
BOOT.CONFIG(5)						      BSD File Formats Manual						    BOOT.CONFIG(5)

NAME
boot.config -- Configuration file for the boot blocks DESCRIPTION
The boot.config file contains options for the FreeBSD boot block code. When the FreeBSD boot loader runs, it searches the ``a'' slice of the boot partition for a boot.config file (as a result, slices which are missing an ``a'' partition require user intervention during the boot process). If the boot.config file is found, its contents are used as the default configuration options for the boot block code and are echoed to the system console. A valid format of this file is to put BIOS drive number, a controller type, a unit number, a partition, a kernel file name, and any other valid boot(8) option on a single line, as it is done at the ``boot:'' prompt. The options related to the boot image selection described below and all the other options available for boot.config are documented in detail in the boot(8) manual page. FILES
/boot.config parameters for the boot blocks (optional) EXAMPLES
The command: # echo "-P" > /boot.config will activate the serial console of FreeBSD. The command: # echo "1:ad(1,a)/boot/loader" > /boot.config will instruct the second stage of boot(8) on the first disk to boot with the third boot(8) stage from the second disk. The command: # echo "1:ad(1,a)/boot/loader -P" > /boot.config will do both of the above. SEE ALSO
boot(8), loader(8) AUTHORS
This manual page was written by Daniel Gerzo <danger@FreeBSD.org>. BSD
May 13, 2007 BSD
All times are GMT -4. The time now is 03:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy