Is there a way to ignore header lines in a UNIX sort?
(head -n 2 <file> && tail -n +3 <file> | sort) > newfile The parentheses create a subshell, wrapping up the stdout so you can pipe it or redirect it as if it had come from a single command.
(head -n 2 <file> && tail -n +3 <file> | sort) > newfile The parentheses create a subshell, wrapping up the stdout so you can pipe it or redirect it as if it had come from a single command.
The very first alias I made once I started customizing my profile in PowerShell was ‘which’. New-Alias which get-command To add this to your profile, type this: “`nNew-Alias which get-command” | add-content $profile The `n at the start of the last line is to ensure it will start as a new line.
Tools are just tools. They help or they don’t. You need help or you don’t. If you know Unix and those tools do what you need them to do on Windows – then you are a happy guy and there is no need to learn PowerShell (unless you want to explore). My original intent was … Read more
Assuming your question regards GNU grep specifically. Here’s a note from the author, Mike Haertel: GNU grep is fast because it AVOIDS LOOKING AT EVERY INPUT BYTE. GNU grep is fast because it EXECUTES VERY FEW INSTRUCTIONS FOR EACH BYTE that it does look at. GNU grep uses the well-known Boyer-Moore algorithm, which looks first … Read more
printf ‘%s\n%s\n’ “to be prepended” “$(cat text.txt)” >text.txt
The nohup command is the poor man’s way of running a process as a daemon. As Bruno Ranschaert noted, when you run a command in an interactive shell, it has a controlling terminal and will receive a SIGHUP (hangup) signal when the controlling process (typically your login shell) exits. The nohup command arranges for input … Read more
Wall-clock time is the time that a clock on the wall (or a stopwatch in hand) would measure as having elapsed between the start of the process and ‘now’. The user-cpu time and system-cpu time are pretty much as you said – the amount of time spent in user code and the amount of time … Read more
If you want to delete lines from 5 through 10 and line 12th: sed -e ‘5,10d;12d’ file This will print the results to the screen. If you want to save the results to the same file: sed -i.bak -e ‘5,10d;12d’ file This will store the unmodified file as file.bak, and delete the given lines. Note: … Read more
The nohup command only writes to nohup.out if the output would otherwise go to the terminal. If you have redirected the output of the command somewhere else – including /dev/null – that’s where it goes instead. nohup command >/dev/null 2>&1 # doesn’t create nohup.out Note that the >/dev/null 2>&1 sequence can be abbreviated to just … Read more
Use the shell globbing syntax: grep pattern -r –include=\*.cpp –include=\*.h rootdir The syntax for –exclude is identical. Note that the star is escaped with a backslash to prevent it from being expanded by the shell (quoting it, such as –include=”*.cpp”, would work just as well). Otherwise, if you had any files in the current working … Read more