Sponsored Content
Full Discussion: Renaming file
Top Forums Shell Programming and Scripting Renaming file Post 302448029 by j_panky on Wednesday 25th of August 2010 05:18:42 AM
Old 08-25-2010
Renaming file

Hello,
I have an outstanding issue..Iam on linux and using a putty to connect to my server and then fire our unix shell script.

At location /usr/sam a file called "er 1 32.txt" out boss transfer via application.
From my end on terminal when i want to transfer this file to some other location or rename this file at the same location is throughs an error..
As the file name is with spaces its not recognizing..
Code:
cp er 1 32.txt /mis/pam

[error]
cp: cannot stat `er': No such file or directory
cp: cannot stat `1': No such file or directory
cp: cannot stat `32.txt': No such file or directory
[error]

How do i transfer this file to some other location as my script run after this file is present otherwise if sends out email saying that the file is unavailable..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming a file to the same name

Hi All, I was wondering if anyone knows how i take in a file, format the file, and then rename the file as the same name as the input file in shell script. Here is an example of what I am doing: if ] then echo "please enter a filename" else export infile=$1 I take in a file... (3 Replies)
Discussion started by: lachino8
3 Replies

2. Shell Programming and Scripting

Renaming a file name

I have an audit log that is produced each day from a production printer. It names the file using todays date, but it removes the leading zero's. For example: todays date 060104 names the file 6104.txt. I ftp this file onto a Sun box and pull stats off of it. To keep some consistency to what I am... (2 Replies)
Discussion started by: dbrundrett
2 Replies

3. UNIX for Dummies Questions & Answers

Help in renaming file !!!

Hi All, I want to rename a file inside a script which has a date portion appended at the start of the file name. The script i wrote works fine when the file comes on a day to day basis but sometimes it comes late too. #!/usr/bin/ksh cd /space/file/source dt=$(date "date "+%m%d%Y")... (5 Replies)
Discussion started by: kumarsaravana_s
5 Replies

4. Shell Programming and Scripting

renaming file

Dear Friends, Need your help once again. I have this file name e.g.1) report_12.rp_1 e.g.2) remark_mm.rmr_3 I want it to be renamed as report_12_1.rp remark_mm_3.rmr (3 Replies)
Discussion started by: anushree.a
3 Replies

5. Shell Programming and Scripting

Renaming a file

I am a complete Unix newbie and I need some help! (Please...) I need to rename a file from the following format: Test_Test_EAR_1234.ear To the following: Test_Test_EAR.ear In other words, I need to remove everything after & including the final underscore up to the "." What is the best... (6 Replies)
Discussion started by: VeloLisa
6 Replies

6. Shell Programming and Scripting

Renaming a file use another file as a sequence calling a shl

have this shl that will FTP a file from the a directory in windows to UNIX, It get the name of the file stored in this variable $UpLoadFileName then put in the local directory LocalDir="${MPATH}/xxxxx/dat_files" that part seems to be working, but then I need to take that file and rename, I am using... (3 Replies)
Discussion started by: rechever
3 Replies

7. Shell Programming and Scripting

File renaming from list of names contained in another file

I have to rename a large number of files so that the name of each file corresponds to a code number that is given side by side in a list (textfile). The list contains in column A the filename of the actual files to be renamed and in column B the name (a client code, 9 digits) that has to be... (7 Replies)
Discussion started by: netfreighter
7 Replies

8. UNIX for Dummies Questions & Answers

Need help with Renaming a file

I have a file named as Pro_PatAct_MMDDYYYY.csv. I need to renmae it to this Pro_PatAct.csv without the date timestamp. Can someone help me to achieve this using a regular expn. (3 Replies)
Discussion started by: imran_affu
3 Replies

9. UNIX for Dummies Questions & Answers

Renaming File

Hi there, I have 350 files in this directory: /home/adams/29 that was mistakenly renamed in this format: TTFILE_BIT_638478.txt.dat I want to take out the trailing .dat so that it ends in .txt: TTFILE_BIT_638478.txt I need help please. Thank you. (6 Replies)
Discussion started by: Creems
6 Replies

10. Shell Programming and Scripting

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.. toMove=`ls | grep -E "partition.+"` mv $toMove partition._org... (7 Replies)
Discussion started by: Priya Amaresh
7 Replies
stat(2) 							System Calls Manual							   stat(2)

NAME
stat, fstat, lstat - Provides information about a file SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int stat( const char *path, struct stat *buffer ); int lstat( const char *path, struct stat *buffer ); int fstat( int filedes, struct stat *buffer ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: fstat(): POSIX.1, XSH5.0 lstat(): POSIX.1, XSH5.0 stat(): POSIX.1, XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the pathname identifying the file. Specifies the file descriptor identifying the open file. Points to the stat structure in which information is returned. The stat structure is described in the <sys/stat.h> header file. DESCRIPTION
The stat() function obtains information about the file named by the path parameter. Read, write, or execute permission for the named file is not required, but all directories listed in the pathname leading to the file must be searchable. The file information is written to the area specified by the buffer parameter, which is a pointer to a stat structure, defined in sys/stat.h. The values of the stat structure's member, mode_t, are defined in <sys/mode.h>. The fstat() function is like the stat() function except that the information obtained is about an open file referenced by the filedes parameter. The lstat() function is like the stat() function except in the case where the named file is a symbolic link. In this case, the lstat() function returns information about the link, while the stat() and fstat() functions return information about the file the link references. In the case of a symbolic link, the stat() functions set the st_size field of the stat structure to the length of the symbolic link, and sets the st_mode field to indicate the file type. The stat(), lstat(), and fstat() functions update any time-related fields associated with the file before writing into the stat structure. [Tru64 UNIX] When run on a file in an AdvFS clone fileset, the value returned for st_blocks is the number of blocks in the original file at the time the clone fileset was created. NOTES
Two structure members in <stat.h> uniquely identify a file in a file system: st_ino, the file serial number, and st_dev, the device id for the directory that contains the file. [Tru64 UNIX] However, in the rare case when a user application has been deleting open files, and a file serial number is reused, a third structure member in <stat.h>, the file generation number, is needed to uniquely identify a file. This member, st_gen, is used in addition to st_ino and st_dev. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the stat() or lstat() function fails, errno may be set to one of the following values: Search permission is denied for a component of the path parameter. Either the buffer parameter or the path parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. Too many links were encountered in translating path. The length of the path parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The file named by the path parameter does not exist or is an empty string. A component of the path parameter is not a directory. [Tru64 UNIX] The structure pointed to by the buffer argu- ment cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for the for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0. [Tru64 UNIX] For NFS file access, if the stat() or lstat() function fails, errno may also be set to one of the following values: The file position pointer associated with the filedes parameter was negative. Indicates either that the request was for a write access to a file but the specified filename was actually a directory, or that the function was trying to rename a directory as a file. Indicates either that the system file table is full, or that there are too many files currently open in the system. Indicates a stale NFS file handle. An opened file was deleted by the server or another client; a client cannot open a file because the server has unmounted or unexported the remote directory; or the directory that contains an opened file was either unmounted or unexported by the server. If the fstat() function fails, errno may be set to one of the following values: The filedes parameter is not a valid file descriptor. The buffer parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. [Tru64 UNIX] The structure pointed to by the buffer argument cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0 or later. RELATED INFORMATION
Functions: chmod(2), chown(2), link(2), mknod(2), open(2), pipe(2), symlink(2), utime(2) Standards: standards(5) delim off stat(2)
All times are GMT -4. The time now is 12:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy