Sponsored Content
Top Forums Shell Programming and Scripting script that looks for .old extension Post 302473624 by Joey12 on Sunday 21st of November 2010 09:28:20 PM
Old 11-21-2010
script that looks for .old extension

Hey guys I have to make a script that takes one argument, the name of a directory, and adds the extension ".old" to all visible files in the directory that don't already have it.

I made one that loops through the file names and uses a grep to see if the extension .old is there and then renames it like this:

Code:
for filename in $(ls "$1")
do
   echo $filename | grep '\.old$' > /dev/null
   if [ $? != 0 ]
      then mv $1/$filename $1/$filename.old
   fi
done

Now I have to Use a for loop to go through the filenames in the directory. But, only loop through the filenames that do not have a ".old" extension. Inside this loop I have to rename the file to the new name. Anyone have any idea how I would do this?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

shell script: forbid extension

Rather new to unix, so please don't beat me! I'm trying to get a list of files into a variable that I can use throughout the rest of the script. The challenge is that I need to exclude a certain extension from the list, and I'm having trouble with it. For example: item_a item_a.exe... (3 Replies)
Discussion started by: Loriel
3 Replies

2. Shell Programming and Scripting

shell script string extension

hey, im looking for a way of extending a string in shell script. for example i have two strings "." and "abcd", i need to extend the first string so that it is the same length as the second. so "." and "abcd" becomes "...." and "abcd", could someone shed light on how to do this ? thanks (4 Replies)
Discussion started by: vbm
4 Replies

3. UNIX for Dummies Questions & Answers

script takes the whole filename instead of just extension

I am running my script from "/abc/" this path and it has no ".csv files" but has a ".txt" files namely temp1.txt My script goes as below, wherein it is suppose to find files with *.txt extension and *.csv extension in another path namely "/abc/xyz/": #!/bin/ksh PATH1="/abc/xyz/" value="*.csv... (1 Reply)
Discussion started by: wolverine999
1 Replies

4. Shell Programming and Scripting

Csh script get file extension

Hi All I have a csh shell script which should check if a given file is a zip file as below: **************************************** #!/bin/csh -f if ]; then echo is a zip file else echo sorry not a zip file endif exit **************************************** ... (1 Reply)
Discussion started by: raj144
1 Replies

5. Shell Programming and Scripting

Script to add extension to filename

Hi all, I have a folder with a bunch of files in them, and I would like to add an extension (.mp3)to all these filenames. The folder has only files that I'd like .mp3 added to. It looks something like this: Intput: File1 File2 File3Output: File1.mp3 File2.mp3 File3.mp3Thanks in... (2 Replies)
Discussion started by: repiv
2 Replies

6. Shell Programming and Scripting

Script to create EVIM template with SAS extension

I write lots of SAS programs and would like to create a script that allows me to have a template each time I create a new program file. Specs: I use EVIM for my editor. I run SAS in batch mode. We use RedHat 6. I don't use c shell. I want a script that will do the following: >... (3 Replies)
Discussion started by: starbecks
3 Replies

7. Shell Programming and Scripting

perl script to remove the extension from its name

There are few files in my windows directory and I need a perl script to rename the files to its original names i.e., the last extension(.orig) needs to be removed programatically, files in directory data1.htm.orig data2.htm.orig data3.htm.orig to be renamed to data1.htm data2.htm... (4 Replies)
Discussion started by: giridhar276
4 Replies

8. Shell Programming and Scripting

shell script to change the extension of a file

I have a directory that contains several files, out of which some files are have an extra extension for example file1.new.new.new file2.new.new.new file3.new.new.new file4.new.new.new i want to write a shell script that rename all such file with only single extension like file1.new... (7 Replies)
Discussion started by: mukulverma2408
7 Replies

9. Shell Programming and Scripting

Finding file extension on C Shell script

I very new to C Shell. I am trying to do is read from Command line. Find the if the file is zip, .txt, symbloic link,pipe, unknow (if file is not zip, txt, sy....) here is what I what got so far. I am very stuck atm Please help me out : If the file is symblooc link what file is link to ... (12 Replies)
Discussion started by: madbull41
12 Replies

10. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies
extend(1)						      General Commands Manual							 extend(1)

NAME
extend -- produce an extended elevation from a .3d file SYNOPSIS
extend [--specfile configuration .espec file] input .3d file [output .3d file] Description Note: The extend program can also work on Compass .plt (as can aven and any other Survex program which reads .3d files). If no specfile is given, extend starts with the highest station marked as an entrance which has at least one underground survey leg attached to it. If there are no such stations, the highest deadend station in the survey (or the highest station if there are no deadends) is used. Extend puts the first station on the left, then folds each leg out individually to the right, breaking loops arbitrarily (usually at junctions). If the output filename is not specified, extend bases the output filename on the input filename, but ending "_extend.3d". For example, extend deep_pit.3d produces an extended elevation called deep_pit_extend.3d. This approach suffices for simple caves or sections of cave, but for more complicated situations human intervention is required. More com- plex sections of cave can be handled with a specfile giving directions to switch the direction of extension between left and right, to explicitly specify the start station, or to break the extension at particular stations or legs. The specfile is in a format similar to cavern's data format: ;This is a comment ; start the elevation at station entrance.a *start entrance.a ;this is a comment after a command ; start extending leftwards from station half-way-down.5 *eleft half-way-down.5 ; change direction of extension at further-down.8 *eswap further-down.8 ; extend right from further-down.junction, but only for ; the leg joining it to very-deep.1, other legs continuing ; as before *eright further-down.junction very-deep.1 ; break the survey at station side-loop.4 *break side-loop.4 ; break survey at station side-loop.junction but only ; for leg going to complex-loop.2 *break side-loop.junction complex-loop.2 This approach requires some trial and error, but gives useful results for many caves. The most complex systems would benefit from an interactive interface to select and view the breaks and switches of direction. See Also 3dtopos(1), aven(1), cad3d(1), cavern(1), diffpos(1), sorterr(1), svxedit(1) extend(1)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy