Sponsored Content
Top Forums Shell Programming and Scripting Remove all digits and rename a file Post 302673117 by scorpioraghu on Tuesday 17th of July 2012 12:58:55 PM
Old 07-17-2012
Hi Jim,

It's giving an error saying...


Command '"./changeBatchID.sh"'
failed with return code 0 and error message
./changeBatchID.sh: line 15: nexus-/27041: No such file or directory
mv: missing destination file operand after `nexus-1234'
Try `mv --help' for more information..


Here is the code I have so far...

Code:
for filename in ./*
 do	

   if [ -f "$filename" ]   
       then
	    file="${filename#*/}"; 
           #echo $file >> $LOGFILE 
	    if [[ "$file" == nexus* ]]
	    then
              var="nexus-1234"
		new_var= "${var/[0-9]*//}$( printf "%04d" ${RANDOM})";
		mv $var $newvar             
  	    fi  
   fi   
 done;

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move and rename files in seq. with padded digits

Greetings, I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out. (9 Replies)
Discussion started by: rocinante
9 Replies

2. Shell Programming and Scripting

Search and remove digits (if exist) from end of the string

Hi Experts, Here is what I am trying to do. 1) say I have a file with below strings database1 database2 database3 data10gdb1 data10gdb2 databasewithoutdigit 2) I want to get the below output. (- if there is any digit at the end of the string, I need to remove it) (- Any... (3 Replies)
Discussion started by: shail_boy
3 Replies

3. Shell Programming and Scripting

BASH: remove digits from end of string

Hi there, im sure this is really simple but i have some strings like this e1000g123001 e1000g0 nge11101 nge3and i want to create two variables ($DRIVER and $INSTANCE). the first one containing the alpha characters that make up the first part of the string, e.g. e1000g or nge and the... (9 Replies)
Discussion started by: rethink
9 Replies

4. Shell Programming and Scripting

Find filenames with three digits and add zeros to make five digits

Hello all! I've looked all over the internet and this site and have come up a loss with an easy way to make a bash script to do what I want to do. I have a file with a naming convention as follows: 2012-01-18 string of words here 123.jpg 2012-01-18 string of words here 1234.jpg 2012-01-18... (2 Replies)
Discussion started by: Buzzman25
2 Replies

5. Shell Programming and Scripting

remove directories with two digits after decimal point

Hi everyone, I am new here and generally not experienced with linux. My question must be easy, but as for now I have no idea how to do it. I have lots of directories with numerical names, e.g. 50 50.1 50.12 etc. What I want is to leave directories with no or single digit after the decimal... (2 Replies)
Discussion started by: cabaciucia
2 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Rename file name / remove part of name

I have a whole file structure with jpeg files where I want to remove a part of the file name. An application added in many files a case conflict in the naming "xyz 017.jpg (Case Conflict 1)" So, can someone help me how to get rid of the " (Case Conflict 1)"? What I have is this: find . -name... (2 Replies)
Discussion started by: borobudur
2 Replies

7. Shell Programming and Scripting

Remove duplicates and update last 2 digits of the original row with 0's

Hi, I have a requirement where I have to remove duplicates from a file based on the first 8 chars (It is fixed width file of 10 chars length) and whenever a duplicate row is found, its original row's last 2 chars should be updated to all 0's. I thought of using sort -u -k 1.1,1.8... (4 Replies)
Discussion started by: farawaydsky
4 Replies

8. Shell Programming and Scripting

Perl Script remove digits and convert

Hello Guy's Quick question which im sure many can answer in seconds. Basically I have a perl script which is running commands to an element and then taking some of the the output and printing it to the screen. One of the outputs is a variable Hex Number. What I would like to do is strip... (1 Reply)
Discussion started by: mutley2202
1 Replies

9. Shell Programming and Scripting

Remove or rename based on contents of file

I am trying to use the two files shown below to either remove or rename contents in one of those files. If in file1.txt $5 matches $5 of file2.txt and the value in $1 of file1.txt is not "No Match" then that value is substituted for all values in $5 and $1 of file2.txt. If however in $1 ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

sed / awk script to delete the two digits from first 3 digits

Hi All , I am having an input file as stated below 5728 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r03_q_reg_20_/Q 011 611 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r04_q_reg_20_/Q 011 3486... (4 Replies)
Discussion started by: kshitij
4 Replies
pcie_pci(7D)							      Devices							      pcie_pci(7D)

NAME
pcie_pci - PCI Express bridge nexus driver DESCRIPTION
The pcie_pci nexus driver is used on X64 servers for PCI Express bridge class devices including PCI Express root ports which are imple- mented as virtual bridges and PCI Express to PCI/PCI-X bridges. The pcie_pci driver is compliant with the PCI Express Base, Revision 1.0a specification and supports Base line PCI Express error handling and PCI Express Hot Plug. FILES
/platform/i86pc/kernel/drv/pcie_pci 32-bit ELF kernel module. /platform/i86pc/kernel/drv/amd64/pcie_pci 64-bit ELF kernel module. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+------------------------------+ |Architecture |x64 PCI Express-based systems | +-----------------------------+------------------------------+ |Availability |SUNWcakr.i | +-----------------------------+------------------------------+ SEE ALSO
attributes(5), pcie(4), npe(7D) PCI Express Base Specification v1.0a --2003 Writing Device Drivers IEEE 1275 PCI Bus Binding -- 1998 http://playground.sun.com/1275/bindings/pci/pci-express.txt SunOS 5.11 12 Oct 2005 pcie_pci(7D)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy