remove pound sign from filename


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers remove pound sign from filename
# 1  
Old 02-13-2002
remove pound sign from filename

Surpisingly, I've only found information regarding removal of files with special characters in the name. My problem is this: files are downloaded to my Unix box from mainframe, and each one has a pound sign as the first character of the filename.

original:

#FONT

what I need:

FONT

Can anyone point me in the right direction here? I feel as though it's "on the tip of my tongue" so to speak.

Thanks,
kristy
# 2  
Old 02-13-2002
Try this script:
Code:
#! /usr/bin/ksh
for file in \#* ; do
     new=${file###}
     if [[ -f $new ]] ; then
         echo $new already exists
     else
         echo mv $file $new
         mv $file $new
     fi
done
exit 0

# 3  
Old 02-13-2002
WOW

that is awesome!
You an element I am not familiar with...Could you explain the line:

Quote:
new=${file###}

Thanks Smilie
# 4  
Old 02-13-2002
Re: WOW

Quote:
Originally posted by kristy
You an element I am not familiar with..
I get that a lot Smilie

${file##x} removes x from the front of a variable. See this post for more info.
# 5  
Old 02-13-2002
oh gosh, USED I meant.

Thanks again, I had no idea.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove spaces in filename

Hi team, Here's a requirement for me. Here are the list of files i have in a unix directory. W 2 A D_2014.csv W 3 A D_2014.csv W 4 A D_2014.csv /home/kmani00-> uname -a AIX sliyyvxx 1 6 00F613E54C00 /home/kmani00-> The file names has to be without spaces as follows. W2AD_2014.csv... (1 Reply)
Discussion started by: kmanivan82
1 Replies

2. Shell Programming and Scripting

How to remove sections of a filename?

Hello, I need some help with renaming some files by removing a certain portion of the filename. The current file name is: ABC_2013186197_20130708_203556.95336 I need to remove the 5 digits after the first "_". The new file name should be: ABC_197_20130708_203556.95336 I'm not quite... (5 Replies)
Discussion started by: bbbngowc
5 Replies

3. Shell Programming and Scripting

remove the filename from a string

I have a string like this /Development/ST/st000001su/Outbound/Prod/PROD-732QCJ/63acf2caf91bc136cb9bcce8a85c7fa8/PGP/PGP.txt I want to remove the PGP.txt and I want only the /Development/ST/st000001su/Outbound/Prod/MCFR-732QCJ/63acf2caf91bc136cb9bcce8a85c7fa8/PGP returned. I saw an command... (2 Replies)
Discussion started by: srini0603
2 Replies

4. Shell Programming and Scripting

How to remove numbers from filename

Hi all, Can I edit this script: find . -type f | while read i;do && mv "$i" "${i//abc/}" ;done so that it will not only take out abc from the filename but also take out any numbers that might be in the filename as well. An example would be, Input: filename abc 2009.mov Output:... (7 Replies)
Discussion started by: Monkey Dean
7 Replies

5. Shell Programming and Scripting

Remove # sign from the file

Hello Friends, i need help to remove "#" sign from a file. I want to remove the "#" marks just in the area mentioned in red. I am not so good in awk, this help would be deeply appreciated. thanks Ado trap = { # { # trap-community = SNMP-trap # hosts = hubble,... (14 Replies)
Discussion started by: asirohi
14 Replies

6. UNIX for Dummies Questions & Answers

Remove path from filename

In a foreach loop I end up with $file containing the filename INCLUDING the whole path. I want this reduced to just the filename, but I can't seem to remember how I did it some years back. I am sure I can do it with "sed", but I am pretty sure I have seen a simpler command. Anyone? borgeh (3 Replies)
Discussion started by: borgeh
3 Replies

7. Solaris

Printing pound sign from Solaris (JETDIRECT)

Hi, Any ideas of the character sequence to print the £ sign from Solaris using network printing over Jetdirect software ? Thanks Matt (1 Reply)
Discussion started by: mattpar75
1 Replies

8. SCO

Printing Sterling Pound Sign

We need to print the sterling pound sign on printers connected directly to a terminal and configured using the /dev/null device. We have used mapchan to enable this on the printers connected directly to the SCO server. Any idea how this can be activated? OS: SCO Open Server 5.0.5 (5 Replies)
Discussion started by: nyasai
5 Replies

9. Shell Programming and Scripting

Sign on/Sign off logging script

I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem. I need... (1 Reply)
Discussion started by: Glider
1 Replies

10. UNIX for Dummies Questions & Answers

remove filename prefix

I've got a bunch of files called oldabc, olddef etc. i want to copy these to be abc, def.... I can do this with file extensions....but can get the logic to work for prefixes. All the files I am interested in have a prefix of 'old'. This loop is no good for me....it looks at the content... (2 Replies)
Discussion started by: peter.herlihy
2 Replies
Login or Register to Ask a Question