LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-15-2009, 07:41 AM   #16
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195

Quote:
Originally Posted by Completely Clueless View Post
Okay, thanks for the clarification, Charles. However, as I stated earlier in this thread......

"I reckon C is far more suited to this particular task, so I'm going to switch at this point. Thanks for all the ideas anyway, guys."
Your almost certainly right (not knowing what this particular task is, I can't be sure but C is way faster than shell) but I didn't want you to change from bash to C because you thought bash could not do it.
 
Old 08-15-2009, 08:31 AM   #17
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 814

Original Poster
Rep: Reputation: 69
Quote:
Originally Posted by catkin View Post
Your almost certainly right (not knowing what this particular task is, I can't be sure but C is way faster than shell) but I didn't want you to change from bash to C because you thought bash could not do it.
That's fine, Charles. I'm sure Bash could do it, but it's more of a C job IMHO. I'm increasingly aware of the strengths and weaknesses of Bash, will continue to learn it and respect it for what it does well. At the same time, I'm going to dust off my rusty old C coding experience and polish up on that, too.

Pushing 90 degrees here again today I'm sorry to say. Now where did I put those salt tablets?
 
Old 08-15-2009, 10:02 AM   #18
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,674
Blog Entries: 14

Rep: Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021
If you like C and want to do scripting very similar to it you might want to investigate Perl.
 
Old 08-15-2009, 11:27 AM   #19
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 814

Original Poster
Rep: Reputation: 69
Quote:
Originally Posted by jlightner View Post
If you like C and want to do scripting very similar to it you might want to investigate Perl.
Sorry, you'll have to excuse my ignorance, but what advantage would that confer?
 
Old 08-15-2009, 11:56 AM   #20
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by Completely Clueless View Post
Sorry, you'll have to excuse my ignorance, but what advantage would that confer?
Familiarising oneself with 3 languages at the same time has great confusion potential++
 
Old 08-15-2009, 12:08 PM   #21
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 814

Original Poster
Rep: Reputation: 69
Quote:
Originally Posted by catkin View Post
Familiarising oneself with 3 languages at the same time has great confusion potential++
Too true, Charles! That's why I am determined to strenuously avoid the psuedo-C constructs that Bash can parse. The syntax isn't *quite* the same, which certainly could cause problems for me in both.
 
Old 08-15-2009, 02:35 PM   #22
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by Completely Clueless View Post
Too true, Charles! That's why I am determined to strenuously avoid the pseudo-C constructs that Bash can parse. The syntax isn't *quite* the same, which certainly could cause problems for me in both.
Which would make PERL an ideal choice to maximise confusion; it looks like a mixture of shellscript and C with its own pathologically eclectic rubbish thrown in for good measure.
 
Old 08-15-2009, 05:52 PM   #23
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by catkin View Post
What's the problem?
The problem is your script removes new lines characters. To avoid it you have to change delimiter:

Code:
#!/bin/sh

> outfile.txt

while read -n1 -d "^["
do
    echo -n "$REPLY" >> outfile.txt
done < infile.txt
 
Old 08-16-2009, 12:10 PM   #24
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
"^[" in the above script doesn't mean two characters: ^ and [ but one character: escape. To get it you could use vim. It's enough to go to editing mode, to press Ctrl-V for literal mode, and to press Esc for escape character.

If you're not acquainted with vim try that sequence:

Open the script with the command: vim your_script_name.
Go to the desired position using arrows.
Press i (lowercase i) for insert mode.
Press Ctrl-V (Ctrl and v) for literal mode.
Press Esc for escape character.
Press Esc to exit editing mode.
Press ZZ (uppercase Z twice) to save changes and exit vim.

Last edited by w1k0; 08-16-2009 at 12:13 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bash scripting: parsing a text file character-by-character Completely Clueless Programming 13 08-12-2009 10:07 AM
CUPS not printing character JMJ_coder Linux - Software 6 03-23-2007 03:36 PM
Printing the octal representation of a character. smoothdogg00 Programming 1 03-02-2006 11:44 PM
ncurses printing character array prob. slzckboy Programming 3 07-31-2005 09:51 AM
Problem with reading and printing a character hubabuba Programming 3 02-28-2005 03:41 PM


All times are GMT -5. The time now is 09:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration