Tag Info

Hot answers tagged

17

root is the superuser account on the system — it (basically) has all privileges. Many systems are configured so that you can use the sudo command in front of another command to run that command "as root" — that is, as if you are the root user, with the same privileges. It is usually the case that you need root privileges to install system packages, which is ...


16

It is a bad idea (to have strange characters in file names) but you could do mv somefile.txt "foo bar" (you could also have done mv somefile.txt "$(printf "foo\nbar")" or mv somefile.txt foo$'\n'bar, etc... details are specific to your shell. I'm using zsh) Read more about globbing, e.g. glob(7). Details could be shell-specific. But understand that ...


12

If you use bash, this command should work. mv a $'b\nc'


6

I know you asked for a mv solution, however, despite the warning, this can be easily done with rename (in the Perl package): ~/tmp$ touch foo ~/tmp$ rename 's/$/\nbar/' foo Unsuccessful stat on filename containing newline at /usr/share/perl5/File/Rename.pm line 69. ~/tmp$ ls foo?bar


6

You could use grep with -A and -B to print exactly the parts of the file you want to exclude but add the -n switch to also print the line numbers and then format the output and pass it as a command script to sed to delete those lines: grep -n -A1 -B2 PATTERN infile | \ sed -n 's/^\([0-9]\{1,\}\).*/\1d/p' | \ sed -f - infile Another way with comm: comm ...


6

don's might be better in most cases, but just in case the file is really big, and you can't get sed to handle a script file that large (which can happen at around 5000+ lines of script), here it is with plain sed: sed -ne:t -e"/\n.*$match/D" \ -e'$!N;//D;/'"$match/{" \ -e"s/\n/&/$A;t" \ -e'$q;bt' -e\} \ ...


4

You need root privileges in order to execute system updates via apt-get. You can switch to a root account using su root. It appears that you do not have the sudo program installed.


4

If you don't mind using vim: $ export PAT=fff A=1 B=2 $ vim -Nes "+g/${PAT}/.-${B},.+${A}d" '+w !tee' '+q!' foo aaa bbb ccc hhh iii -Nes turns on non-compatible, silent ex mode. Useful for scripting. +{command} tell vim to run {command} on the file. g/${PAT}/ - on all lines matching /fff/. This gets tricky if the pattern contains regular expression ...


4

One aspect of this problem isn't really about awk - and only a little bit about the shell. The problem is that on a standard, canonical tty most of the time the kernel's tty discipline is buffering your input - just echoing it to your screen and nowhere else - so that it can efficiently handle backspacing and such-like. However, when you press return or ...


3

There is the prips utility which generates an IP list from a range or CIDR. Useful for work with large ranges: $ prips 10.0.0.20 10.0.0.23 10.0.0.20 10.0.0.21 10.0.0.22 10.0.0.23 $ prips 10.0.0.0/23 10.0.0.0 10.0.0.1 10.0.0.2 <...> 10.0.1.254 10.0.1.255


2

The printf command performs implicit iteration if it is given more arguments than conversion specifiers. For example: $ printf "%s-%s\n" 1 2 3 4 5 6 1-2 3-4 5-6 There are two conversions, but six arguments. So three repetitions of the formatting logic occur, marching over the arguments pairwise. With that we can do: printf "10.0.0.%s\n" $(seq 1 23) ...


2

This has nothing to do with bash, it is purely an effect of the terminal's behavior, specifically scroll. When you reach the bottom of the screen, and start to type on the next line, the terminal creates a new blank line by pushing everything up one line. (In older terminals this destroys the top line. In newer terminals the top line is just pushed into the ...


2

It stands for "Block Identification". 1* I general, using whatis can provide info about a command: whatis blkid A block (device) is a file that provides buffered access to hardware. E.g a hard-drive. Futher info: https://en.wikipedia.org/wiki/Device_file#Block_devices Each block device listed by blkid has a unique universal Identifier (UUID). blkid ...


1

What does “are you root?” mean? In order to install packages systemwide (what apt-get does), it needs root privileges, since you will be creating and changing system files (root is the usual name for the *nix administrator account). The «are you root?» message is a gentle reminder that you "need to be root" in order to run apt-get install. This is the most ...


1

How about (using GNU grep and bash): $ grep -vFf - file.txt < <(grep -B2 -A1 'fff' file.txt) aaa bbb ccc hhh iii Here we are finding the lines to be discarded by grep -B2 -A1 'fff' file.txt, then using this as an input file to find the desired lines discarding these.


1

I found it! history [n] An argument of n lists only the last n lines. $ echo "hello how are you" $ history 2 1060 echo "hello how are you" 1061 history 2


1

I didn't bother researching how to import missing modules and such. That's a pretty steep learning curve for my taste, as I am only starting to use GNU/Linux. Instead, I formatted the UFD with ext4 using a healthy Ubuntu installation on another PC. I was then able to mount it on the patient PC, and from there I only had to copy the file. In terminal on the ...


1

The following solution is based on nothing but xxd (one of the tools mentioned in the question), Bash and GNU sed. It assumes that the input consists of complete bytes (groups of eight letters), arbitrarily separated by newlines. The approach is: Strip all newlines. Group letters into four-letter groups terminated by spaces. Filter these quadgraphs into ...


1

scim is the best command line spreadsheet right now. It compiles easily on OSX. You have to make one modification to the source code to fix the backspace key on OSX. https://github.com/andmarti1424/scim


1

I found the best option was to upgrade freerdp following these guidelines: In Terminal: $ cd /usr/src $ git clone git://github.com/FreeRDP/FreeRDP.git $ cd FreeRDP $ sudo aptitude install libcunit1-dev libdirectfb-dev xmlto doxygen \ libxtst-dev libavutil-dev libavcodec-dev build-essential git-core \ cmake libssl-dev libx11-dev libxext-dev ...



Only top voted, non community-wiki answers of a minimum length are eligible