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 03-18-2010, 12:40 AM   #16
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15

Also, is there any way to increase the acceptable range of multiplier {}?
 
Old 03-18-2010, 12:40 AM   #17
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Code:
root@reactor: sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
root@reactor:
Note the bold command above. Yours should respond similarly to the --version argument, or perhaps the -v argument.

Sasha
 
Old 03-18-2010, 12:47 AM   #18
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15
i typed the following command.

> sed --version
sed: illegal option -- -
Usage: sed [-n] [-e script] [-f source_file] [file...]
 
Old 03-18-2010, 12:54 AM   #19
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
How about:

sed -v
sed -version
sed -V

Any of those work? The man page should show the --version option syntax.
 
Old 03-18-2010, 12:56 AM   #20
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15
none
 
Old 03-18-2010, 12:59 AM   #21
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
How about
sed -h
sed --help
 
Old 03-18-2010, 01:00 AM   #22
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Good grief!! Well, we know it is not GNU sed.

Someone may have mentioned this already, but: consider upgrading it if possible, or installing a newer/better version along side.

Sasha
 
Old 03-18-2010, 01:21 AM   #23
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by crts View Post
How about
sed -h
sed --help
none of these worked
 
Old 03-18-2010, 01:22 AM   #24
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by GrapefruiTgirl View Post
Good grief!! Well, we know it is not GNU sed.

Someone may have mentioned this already, but: consider upgrading it if possible, or installing a newer/better version along side.

Sasha
its on client server.
I can't upgrade it.
 
Old 03-18-2010, 02:30 AM   #25
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Alright, then let's try it the hard way. Yes! Workaround. Try replacing your sed command with the following commands:
Code:
sed -n '${RowNum} s/\(.*\)/\1/p' $FILE_NAME  > temporary1
cut -b 1-$ColNumFrom temporary1 > temporary2
echo "$Data" > temporary3
cut -b $(($ColNumFrom+$Diff+1))- temporary1 > temporary4
cat temporary2 temporary3 temporary4 | tr -d '\n' > temporary5
echo >> temporary5
sed '2 {
       r temporary5
       d
}' $FILE_NAME >> /path/to/your/new/file
Since I do not know the exact format and length of your files some boundary issues might arise. I will leave it up to you to figure that out. I tried the code with a dummy file which had lines longer than 255 chars and it worked. Maybe there is also a way to shorten the above code. However my focus was on functionality.

Last edited by crts; 03-18-2010 at 12:00 PM. Reason: removed '-' in filenames
 
Old 03-22-2010, 03:55 AM   #26
leena_d
LQ Newbie
 
Registered: Dec 2009
Posts: 26

Original Poster
Rep: Reputation: 15
I Tried.

Same error...
 
Old 03-22-2010, 06:34 AM   #27
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by leena_d View Post
I Tried.

Same error...
Which of the two sed instructions gave the error?
[EDIT]
Did you try replacing the first sed
Code:
sed -n '${RowNum} s/\(.*\)/\1/p' $FILE_NAME  > temporary1
with
Code:
sed -n '${RowNum} s/.*/&/p' $FILE_NAME  > temporary1
?

Last edited by crts; 03-22-2010 at 06:51 AM.
 
Old 03-22-2010, 07:25 AM   #28
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Is using something else then sed an option? I was thinking of something like
Code:
count=1
while read line
do
if [ $count == $RowNum ]
then
    < do stuff to line and append it to /path/to/your/new/file >
else
    echo "$line" >> /path/to/your/new/file
fi
count=$((count+1)) # increment count
done
Since you are working on an old system I am not sure if string-manipulation will work. If not you can echo $line into a temp-file first and use the cut and cat instructions from my previous post and then append the resulting file to your new file. I am also not sure if incrementing your count var will work exactly the same way on your system.
 
Old 03-22-2010, 08:18 AM   #29
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
What is the output from sed --version?
 
Old 03-22-2010, 08:34 AM   #30
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by catkin View Post
What is the output from sed --version?
http://www.linuxquestions.org/questi...ml#post3902734
 
  


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
build php 5 2 12 without mysql on hpux: configure error sed: Function s%@MYSQL_LIBS@% etaoinbe Other *NIX 0 01-28-2010 05:01 AM
Shell / function / sed jchambers Programming 3 10-28-2007 05:18 PM
php not being parsed properly hiren_bhatt Linux - General 3 04-01-2007 02:20 AM
/etc/modprobe.conf not being parsed? mrjamin Fedora 1 01-18-2006 02:33 PM
Non-Parsed-Header scripts soulsniper Linux - Software 0 11-22-2003 02:33 PM

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

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