ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.