Sponsored Content
Full Discussion: Need to change of file
Top Forums Shell Programming and Scripting Need to change of file Post 302348268 by methyl on Thursday 27th of August 2009 07:48:51 PM
Old 08-27-2009
"TonyFullerMalv" solution is cool because it follows logical lines. "danmero" solution is naive.

Slight improvement if we quote every filename and every ".", and allow for no files:

Code:
ls -1 *\.conf\.bad 2>/dev/null | while read SFILE
do
  TFILE=`echo "${SFILE}" | sed 's/.bad//'`
  mv "${SFILE}" "${TFILE}"
done


Last edited by methyl; 08-27-2009 at 08:53 PM.. Reason: Allow for no files
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with multiple file rename - change case of part of file name

Hi there, I hope someone can help me with this problem : I have a directory (/var/www/file/imgprofil) which contains about 10000 JPG files. They have a naming convention thus : prefix-date-key-suffix.jpg they all have the prefix p-20050608- then AAAA is a 4 letter code the suffix is... (7 Replies)
Discussion started by: steve7
7 Replies

2. UNIX for Dummies Questions & Answers

How to change the file modification time of a file on nfs mount point

Hi I am accessing a file on nfs mounted device, after completing using of the file, i am tring to restore the access time and modification times of the file. So i got the previous modified time of the file using stat() function and trying to set the date and time for the file, To set these... (6 Replies)
Discussion started by: deepthi.s
6 Replies

3. Shell Programming and Scripting

how to change the current file processing to some other random file in awk ?

Hello, say suppose i am processing an file emp.dat the field of which are deptno empno empname etc now say suppose i want to change the file to emp.lst then how can i do it? Here i what i attempted but in vain BEGIN{ system("sort emp.dat > emp.lst") FILENAME="emp.lst" } { print... (2 Replies)
Discussion started by: salman4u
2 Replies

4. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

5. Shell Programming and Scripting

Help i want to change the data of one file and apend it into 2nd file.

Hi All, Please help i have written an ksh script, where i am actually take count of lines in one file and want to update this count to 2nd field of a new file and apend the this into an existing file. Note the below script is in for loop -------- I am apending few records in a file... (7 Replies)
Discussion started by: iamnoone
7 Replies

6. Shell Programming and Scripting

add line in file and change file name

HI I have 100 files in below folder:- /home/lkj/TEST File name like below undo_ARL01003_120907-155022.mos undo_ARL01006_120908-155042.mos i want replace one first line of each file to pt all i want change file name as below. ARL01003.mos ARL01006.mos Thanks (2 Replies)
Discussion started by: asavaliya
2 Replies

7. Shell Programming and Scripting

Change the file name and copy old file content to new file names.

Hi, I have a files in a directory as below :- ls -1 mqdepth-S1STC02 proc-mq-S1STC01 proc-mq-S1STC02 proc-mq-S1STC03 Whereever i have S1STC i need to copy them into new file with file name S2STC. expected output :- ls -1 mqdepth-S2STC02 proc-mq-S2STC01 proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies

8. Shell Programming and Scripting

Trying to take file numbers from a file, pass them to sed to change strings in corresponding lines

I have a bunch of file numbers in the file 'test': I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working: cat test |... (3 Replies)
Discussion started by: crunchgargoyle
3 Replies

9. Shell Programming and Scripting

Change in the file

Hi, I have a file which has wrong time format and we want to correct it before we load it. WRONG FORMAT : 93:0:00 CORRECT FORMAT :09:30:00 If you notice the 0 at the front is missing. Its the case always. (6 Replies)
Discussion started by: varun22486
6 Replies

10. UNIX for Beginners Questions & Answers

How to change name of the file with first line of the file which has some unwanted text in it?

I have a log file, which i have divided into 14 files using csplit, the file looks like below test-000000 test-000001 #and so on until 14 now I want all the 14 files generated to be renamed as the some part of test in first line of the file how can i eliminate the unwanted text? sample... (5 Replies)
Discussion started by: Sekhar419
5 Replies
BADSECT(8)						      System Manager's Manual							BADSECT(8)

NAME
badsect - create files to contain bad sectors SYNOPSIS
/sbin/badsect sector ... DESCRIPTION
Badsect makes a file to contain a bad sector. Normally, bad sectors are made inaccessible by the standard formatter, which provides a for- warding table for bad sectors to the driver; see bad144(8) for details. If a driver supports the bad blocking standard it is much prefer- able to use that method to isolate bad blocks, since the bad block forwarding makes the pack appear perfect, and such packs can then be copied with dd(1). The technique used by this program is also less general than bad block forwarding, as badsect can't make amends for bad blocks in the i-list of file systems or in swap areas. Adding a sector which is suddenly bad to the bad sector table currently requires the running of the standard DEC formatter, as UNIX does not supply formatters. Thus to deal with a newly bad block or on disks where the drivers do not support the bad-blocking standard badsect may be used to good effect. Badsect is used on a quiet file system in the following way: First mount the file system, and change to its root directory. Make a direc- tory BAD there and change into it. Run badsect giving as argument all the bad sectors you wish to add. (The sector numbers should be given as physical disk sectors relative to the beginning of the file system, exactly as the system reports the sector numbers in its con- sole error messages.) Then change back to the root directory, unmount the file system and run fsck(8) on the file system. The bad sectors should show up in two files or in the bad sector files and the free list. Have fsck remove files containing the offending bad sectors, but do not have it remove the BAD/nnnnn files. This will leave the bad sectors in only the BAD files. Badsect works by giving the specified sector numbers in a mknod(2) system call (after taking into account the filesystem's block size), creating a regular file whose first block address is the block containing bad sector and whose name is the bad sector number. The file has 0 length, but the check programs will still consider it to contain the block containing the sector. This has the pleasant effect that the sector is completely inaccessible to the containing file system since it is not available by accessing the file. SEE ALSO
mknod(2), bad144(8), fsck(8) BUGS
If both sectors which comprise a (1024 byte) disk block are bad, you should specify only one of them to badsect, as the blocks in the bad sector files actually cover both (bad) disk sectors. On the PDP-11, only sector number less than 131072 may be specified on 1024-byte block filesystems, 65536 on 512-byte block filesystems. This is because only a short int is passed to the system from mknod. 3rd Berkeley Distribution BADSECT(8)
All times are GMT -4. The time now is 10:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy