I have a file, with some HTML in it.
I would like to make a shell/bash script that moves ALL of the content of that file into ANOTHER HTML file at a CERTAIN line number...
Does anyone have any suggestions?
If not possible at a certain line, then at the END of the file.
# put it at the end
cat tomove.html >> toreceive # note >>, not >
There are a variety of ways to put it at a particular spot in the file. You will need a temporary file to hold either the original torecieve or the new one. Lets assume you will build into the temporary and then rename it.
# put it after line 25
head -25 torecieve> tempreceive
cat tomove.html >> tempreceive
tail +26 toreceive >> tempreceive # note the plus sign
mv toreceive old-toreceive
mv tempreceive toreceive
Or you could use sed ... with the r (read file here) command. Similar pattern: Work from existing file into a temp file, then rename.
Either the script or with sed, you could instead first rename the original file to a tempame, then build the new file in place. If this fails, though, it is harder to get back to the initial state.
Not at all: head -25 gives you the first 25 lines, and tail +26 gives you everything from line 26 onward. Don't think 'head minus twentyfive', think 'head dash twentyfive': it is a flag (use line 25). The head command is ancient, and does not quite conform to what is now standard practice for unix utilities. Similarly for tail.
If you are satisfied that your issue is solved, please be sure to mark it with the 'solved' button. Thanks.,
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.