LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-22-2008, 02:53 AM   #1
bkcreddy17
Member
 
Registered: Feb 2008
Location: India-Hyderabad
Distribution: RHEL and Fedora
Posts: 171

Rep: Reputation: 15
Unhappy Files with ~ mark at the end


When does a file get extension ~ .suppose there is a file called script.sh. It was converted to script.sh~ . To edit them in GUI mode, i am not able to see, even as hidden files. How do i remove ~ mark at the end of the file? I did few file manually
Code:
mv script.sh~ script.sh
But there are many files across the system. How do i do it?
 
Old 11-22-2008, 03:31 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
These are backup files created by some GUI editors, like gedit. You can:
1) disable the creation of the backup files, from the editor's options
2) enable the file manager to show backup files
3) remove them all in a single shot:
Code:
find . -name \*~ -exec echo rm {} \; # the echo is for testing
If you don't feel the backup files are necessary, you can apply points 1 and 3 above.
 
Old 11-22-2008, 08:32 AM   #3
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

to remove the files I'd prefer:
Code:
find . -name \*~ -print0 | xargs -0 rm
- doesn't call a new rm process for each file
- can handle filenames with blanks and other special characters.

Jan
 
Old 11-22-2008, 08:52 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by jan61 View Post
- doesn't call a new rm process for each file
- can handle filenames with blanks and other special characters.
True the first statement, not the second. The -exec action handles spaces and special character, too.
 
Old 11-26-2008, 10:08 AM   #5
nehaandrew
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
This should do the trick
(I think!)


================================
for i in `find . -name \*~`;
do
rm -rfv $i
done

================================

Linux

Last edited by nehaandrew; 11-30-2008 at 01:18 AM.
 
Old 11-26-2008, 10:11 AM   #6
nehaandrew
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
You might need to do some testing of the above script to see it works fine.

Last edited by nehaandrew; 11-26-2008 at 10:15 AM.
 
Old 11-26-2008, 01:05 PM   #7
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

Quote:
Originally Posted by nehaandrew View Post
You might need to do some testing of the above script to see it works fine.
yes:
Code:
jan@jack:~/tmp/ugly> ll
total 0
-rw-r--r--  1 jan users 0 Nov 26 19:58 file with?newline~
-rw-r--r--  1 jan users 0 Nov 26 19:58 file with a ' inside~
-rw-r--r--  1 jan users 0 Nov 26 19:58 file with blanks~
-rw-r--r--  1 jan users 0 Nov 26 20:00 file with ctrl-c ?inside
jan@jack:~/tmp/ugly> for i in `find . -name \*~`;
> do
> ls "$i"
> done
/bin/ls: ./file: No such file or directory
/bin/ls: with: No such file or directory
/bin/ls: a: No such file or directory
/bin/ls: ': No such file or directory
/bin/ls: inside~: No such file or directory
/bin/ls: ./file: No such file or directory
/bin/ls: with: No such file or directory
/bin/ls: blanks~: No such file or directory
/bin/ls: ./file: No such file or directory
/bin/ls: with: No such file or directory
/bin/ls: newline~: No such file or directory
Jan
 
Old 11-27-2008, 04:35 AM   #8
nehaandrew
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
(Swallowing my ego) Thanks for the info Jan61.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question Mark appended to the end of file names mts7 Linux - Server 5 09-18-2008 08:41 PM
display files don't end with . powah Linux - General 3 06-08-2007 01:32 PM
LXer: Linux Contributors Mark Year-End With Major Serviceability Improvements LXer Syndicated Linux News 0 12-13-2006 02:33 PM
vim: mark end-of-line? trim blank lines? prell Linux - Software 3 09-20-2004 11:04 PM
what exactly are files that end in .so rolandkirk55 Linux - Newbie 4 09-07-2004 04:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration