Note: You may be tempted to use # THIS WILL GIVE YOU AN EMPTY FILE!īut this will give you an empty file. I wonder how they managed that tail should just read a file line by line while sed does pretty complex operations involving interpreting a script, applying regular expressions and the like. The BSD version can be much slower than sed, though. Check the FreeBSD or OS X man pages for more. tail is also available on BSD and the -n 2 flag is consistent across both tools. tail -n 1 would print the whole file, tail -n 2 everything but the first line, etc. The sign kind of inverts the argument and make tail print anything but the first x-1 lines. tail -n 5 would give you the last 5 lines of the input. Now working, i was missing a space #!/bin/bashĭone < /Applications/SongKong.app/Contents/ist ' /Applications/SongKong.app/Contents/istīut get error sed: 1: "/Applications/SongKong.": invalid command code SĪnd I tried the bash solution #!/bin/bashĬat mergefile.txt # or echo or printf your extra lines I tried Sed solution sed -i '/1.0/ a CFBundleHelpBookFolder\ Thanks for the solution, although I havent managed to get them working yet: SONGKONG NOT UPDATING FILENAME HOW TOI'm using Mac OSX so I can make use of unix comand line tools, but Im not very familiar with such tools and cannot work out how to do this. I want to automate this process as it is part of my build process. I can gurantee that this line will always be in the file but I cannot guarantee excalty what line it will be on so I want the additional lines to be added on the basis of the position of this line rather than adding to a fixed rownumber. How do insert lines of text into file after a particular line in unix ?īackground: The file is an autogenerated textfile but I manually have to edit it every time it is regenerated to add in 4 additional lines after a particular line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |