Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] SED question



On Tue, Oct 04, 2011 at 11:45:22AM -0400, Nathan Meyers wrote:
> On Tue, Oct 04, 2011 at 11:35:00AM -0400, Chandler, Scott wrote:
> > I've got a script running a sed command that I need help interpreting. The line is "sed '$d' file1.txt > file2.txt".
> > 
> > I understand that sed '$d' file1.txt removes the last line from the file but will the resultant file (file2.txt) contain only the last line from file1.txt or will it contain everything *except* the last line from file1.txt?
> 
> Hello Scott,
> 
> The output of sed (what ends up in file2.txt) is the result of applying
> the edit - in this case, it will be the input file contents with the
> last line removed.

Another way to do this particular thing would be:

head -n -1 file1.txt > file2.txt

If you wanted to only keep the last line, tail -1 is your
friend.

-dsr-

-- 
http://tao.merseine.nu/~dsr/eula.html is hereby incorporated by reference.
You can't fight for freedom by taking away rights.



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org