Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Last line of a file
Name: Brian Date: August 22, 2003 at 13:59:46 Pacific OS: UNIX CPU/Ram: LOTS
Comment:
Hello, Recently began writing some UNIX scripts with a lot of success. One problem I have encountered that really stumps me. In an alias file, after I have removed all the users identified in another file I need to ensure that every line has a comma ( I have this part) EXCEPT the very last line. I need to know how to remove something only from the last line of test!!
Name: James Boothe Date: August 22, 2003 at 14:55:05 Pacific
Reply:
sed can target certain lines, then make substitutions just on those lines. For example, for each line that contains xyz, change each occurrence of foo to bar:
sed '/xyz/s/foo/bar/g' myfile
Or it can target a specific line. In the following, the last line only is targeted to change a comma at the end of the line to null:
Summary: Hi, Can someone tell me how to append some text to the last line. Basically i have a last line of a file as follows user1:password i would like to append ':systemuser' to the last line of this file a...
Summary: How do i delete first line of a file. The file starts with page break ^L. The first line contains the page break ^L. The file may have multiple pagebreaks and I don't want to delete from the file. I ...
Summary: Not to be dense, but can you clarify that for me? I'm printing to a printer called comprm, and I want the last, say, 500 lines of a file called PA8513.R01 So would I enter: lpr comprm tail -500 ...