• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Ubuntu newbie question

nemesismk2

Diamond Member
I have only been using Ubuntu for a short time because i want it to replace Windows XP on a spare computer. I do lots of editing of text and files so i was wondering if there was software like http://www.areplacetool.com for editing text/renaming files etc so i can edit 1000's of files quickly. I have asked the people who make the software twice so far and they have not replied.
 
While @Jodell88's suggestion is interesting enough that I'm going to check it out, I might suggest another: krename, which is a kde batch renaming app. It will work in gnome, but if you don't have kde apps already installing it will bring along a lot of kde libraries and assorted dependenies. It's worth it, though, because kde has a lot of great software.
 
The makers of Advanced Replace Tools have replied and have told me to use Wine which allows Linux to launch Windows programs under Linux. This is great news because i use Advanced Replace Tools all of the time.
 
That's one option, if it works well enough, but WINE should only be used as a last resort. Linux has literally thousands of ways to manipulate text and files in batch but most require some effort to learn. If you're sticking with Linux I would recommend learning sed and at least one scripting/programming language like perl or Python.
 
Linux / Unix sed: Delete Word From File / Input
by VIVEK GITE on SEPTEMBER 14, 2012 · 5 COMMENTS· last updated at SEPTEMBER 15, 2012

I've a file as follows:

This is a test.
One bang two three
Foo dang Bar
001 0xfg 0xA
002 0xA foo bar 0xfG
I'm done

Tutorial details
Difficulty Intermediate (rss)
Root privileges No
Requirements sed and bash/ksh

How do I delete all "words" from the above file which ends with a particular letter (say 'g') in each line? The output should be as follows:

This is a test.
One two three
Foo Bar
001 0xA
002 0xA foo bar
I'm done

How do I delete regex-based word using sed or awk under Linux / Unix like operating systems?

You can use any standard Unix text editing and processing utility to find and replace/delete words from the file.
Sed example

The syntax is:


sed 's/\<word\>//g' input
sed -e 's/\<regex-for-word\>//g' input > output

In this example, delete foo word from input:


echo 'This is a foo test' | sed -e 's/\<foo\>//g'

To delete all words ending with a letter 'g' in each line, enter:


sed -e 's/\<[a-zA-Z0-9]*[g|G]\>//g' input

Awk example

The syntax is:


awk '{gsub("word", "");print}' input
awk '{gsub("regex", "");print}' input > output

In this example, delete bar word from input:


awk '{gsub("bar", "");print}' <<< "This is a bar test"

To delete all words ending with a letter 'g' in each line using gnu/awk, enter:


awk '{gsub("[a-zA-Z0-9]*[g|G]$", "");print}' input

Or


awk '{gsub("\\<[a-zA-Z0-9]*[g|G]\\>", "");print}' input
 
Scripting may seem like a PITA, and harder than using a ready made gui tool, but it's only "harder" in one sense. It can take some learning, and you can't just guess where to go as you can by opening a gui program and poking around. It becomes easier when your script falls short of expectations. When that happens, you just add the functionality you need. If that happens with a gui program, you file a feature request, and hope for the best, or look around for another program that does what you want. Alternatively, you can rewrite the program assuming it's libre(which your program isn't), but that's whole new level of difficulty.

What I'm saying, is learning the built in tools carries a lot of value. You may not be able to get up and running in a couple minutes, but the effort you put in will pay off in the long term, both in portability across GNU/Linux systems, and extending functionality without adding a lot of extra work.
 
Scripting may seem like a PITA, and harder than using a ready made gui tool, but it's only "harder" in one sense. It can take some learning, and you can't just guess where to go as you can by opening a gui program and poking around. It becomes easier when your script falls short of expectations. When that happens, you just add the functionality you need. If that happens with a gui program, you file a feature request, and hope for the best, or look around for another program that does what you want. Alternatively, you can rewrite the program assuming it's libre(which your program isn't), but that's whole new level of difficulty.

What I'm saying, is learning the built in tools carries a lot of value. You may not be able to get up and running in a couple minutes, but the effort you put in will pay off in the long term, both in portability across GNU/Linux systems, and extending functionality without adding a lot of extra work.

That is great advice. I do have some programming experience but that was with the Atari ST so a long long time ago. lol
 
Ubuntu should have the 'rename' command, so nothing needs to be installed; just 'man rename'. To use 'rename', still need to know a bit about regular expressions, substitutions, etc...; like StitchExperimen's examples.

gprename [0], is a GUI option. But like others have said, it is better to learn the command line way of doing things.

[0] http://gprename.sourceforge.net/
 
Back
Top