LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-20-2008, 07:47 PM   #16
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940

Categorically speaking, when I run into complex tasks like these, I (now...) instinctively turn to the Perl programming-language.

My essential point, though, is that you should turn to some "programming language." Perl, Python, PHP, and Ruby are all probably within easy reach. You can write a command-line script in any of these, just as easily as you can any shell-script, and no one will know or care exactly how you did it.

"Shell scripting" is a great resource, but I think it's best "in small doses." It is only one of the guns in your holster, and really it's the least one.

The Perl folks like to say "TMTOWTDI = There's More Than One Way To Do It," and while they sometimes carry that thought to an extreme there is a lot of truth to it. Linux/Unix gives you an uncommonly-rich programming environment vis-a-vis "You Know Who." It is well worth your time to explore the full extent of just what has been exciting computer-programmers since the 1970's...
 
Old 06-21-2008, 01:34 PM   #17
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by sundialsvcs View Post
It is well worth your time to explore the full extent of just what has been exciting computer-programmers since the 1970's...
The shell? :}

Perl has only been around since '87



Cheers,
Tink
 
Old 06-22-2008, 07:26 PM   #18
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
I moved the post at the request of the poster.
 
Old 06-23-2008, 04:28 AM   #19
MheAd
Member
 
Registered: Jun 2007
Distribution: Ubuntu 14.04
Posts: 186

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by Mr. C. View Post
Hmmm. What happens with these two commands? :
Code:
printf "\304\n"
printf "\304\n" | tr '\304' A
You can copy/paste directly.

The first one prints just an empty row.
The second one just prints 'A' on a new row.
 
Old 06-23-2008, 05:10 AM   #20
MheAd
Member
 
Registered: Jun 2007
Distribution: Ubuntu 14.04
Posts: 186

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by jschiwal
sed y/[[=a=
[=o=]/ao/
may translate accented a's and o's. I haven't tried this and attempting to type these characters on my keyboard might lead to physical injury!
By adding an additional pipe with command

Code:
sed 'y/äåö/aao/'
to the huge command string that I've made earlier, it seems to be working. Is there any way I could implement the y-thingie to the existing sed that handles the other part, or is the new pipe with the new sed above the only way?
 
Old 06-23-2008, 12:41 PM   #21
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
You've demonstrated that your system WILL translate the characters using the tr command. Just tack those characters to the end of the string1 (from) and string2 (to) arguments.

Alternatively, you can add another expression to your existing sed:

sed -e expr1 -e expr2

you already have expr1, just add the -e's and add your second expression.
 
Old 06-23-2008, 01:05 PM   #22
MheAd
Member
 
Registered: Jun 2007
Distribution: Ubuntu 14.04
Posts: 186

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by Mr. C. View Post
You've demonstrated that your system WILL translate the characters using the tr command. Just tack those characters to the end of the string1 (from) and string2 (to) arguments.

Alternatively, you can add another expression to your existing sed:

sed -e expr1 -e expr2

you already have expr1, just add the -e's and add your second expression.
Alright, it appears that tr indeed does translation.
It translates, however, every desired character twice. Eg:

echo Ö | tr 'Ö' 'O'

becomes: OO

This only happens to special Swedish characters.

Sed option, on the other hand, works like a charm. But I think I'll let you go now guys. You've been more than helpful!
Thank you!
 
Old 06-23-2008, 10:22 PM   #23
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can also include different sed commands in the string separated by semicolons.

sed 'expr1;expr2;expr3' file
 
  


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
shell script to find an word or words from a line rakesh.tandur Linux - General 5 05-13-2008 01:57 PM
Need to strip words from front of line. sed/awk/grep? joadoor Linux - Software 6 08-28-2006 04:39 AM
BASH: First words in a line JordanH Programming 7 10-24-2004 10:00 AM
Command line extract Daunted Linux - Software 2 09-30-2004 05:37 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:27 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