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.
The thing is that the command for sed resembles the following
Code:
sed 'address action' file_name
Now if I want to place another command like grep or cut in the address field how do I do it. Actually I don't know the line number. The user has to give it as an input.
Suppose that I have a variable which contains the required line number in a file. Now how can I use this variable as the address for sed command????????
On my system (home folder) it produces 6 filenames, some with periods before the extensiong, and all separated by newlines. Pretty much guaranteed to make the SED addressing go berserk.
In the form I showed, you have to filter the output of the command to get something that is rational to use as an address.
Suppose that I have a variable which contains the required line number in a file. Now how can I use this variable as the address for sed command????????
SED addressing takes numbers and or strings--
eg:
sed -n '1p' filename #prints line 1
sed -n '1,5' filename #prints lines 1-5
sed -n '1,/keyword/' #prints line thru the line containing "keyword"
The first field is the roll no of a student. Now I have to take a roll no as an input and delete the whole entry making use of SED command.
So can You help me out....
Just as a matter of interest can you tell me some other ways...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.