Tag Info

Hot answers tagged

9

Why can you continue viewing a movie although it's been deleted? Because the file descriptor might be gone, but the inode is still there! And only when the inode gets deleted, is the file gone forever! So in your case: when you cd to / and all files in that tree are closed will the inodes be recycled and will the directory be gone foreverĀ¹... ...


7

less is the wrong tool for the job. You can use cat for that: cat -n file1 >file2 Or nl: nl -ba file1 >file2 Or pr: pr -n -t -T file1 >file2 Or sed: sed '/./=' file1 | sed '/./N; s/\n/\t/' >file2 Or grep: grep -n . file1 | sed 's/:/\t/' >file2 Or awk: awk '{ $0 = NR "\t" $0 } 1' file1 >file2 Or again awk: awk '{ sub(/^/, ...


5

I think pwd you run was a bash shell built-in. It just printed out the path it held in memory without looking up the file system. $ type pwd pwd is a shell builtin $ /bin/pwd /bin/pwd: couldn't find directory entry in '..' with matching i-node


5

nc writes its output to standard error, you need: nc -zvv localhost 31000-32000 2>&1 | grep succeeded The 2>&1 will redirect standard error to standard output so you can then pipe it to grep.


5

Looks like redirecting standard input may work for you. Try creating a file (named 'myinput') with two lines: I (the key goes here) and run your command again like this: cmd < myinput The less-than sign above will send the contents of 'myfile' to your command as if it was typed on the keyboard. If your command is actually a shell script you may ...


5

This works. ^ denotes start of line, plus the {32} you already had, then a $ for end of line. $ cat fileA fileB 12345678901234567890123456789012 123456789012345678901234567890123 12345678901234567890123456789012 123456789012345678901234567890124 $ grep -E "^.{32}$" fileA fileB fileA:12345678901234567890123456789012 fileB:12345678901234567890123456789012 $ ...


3

screenfetch does that also. It also includes themes.


2

A simple solution is to suspend the running command, usually by typing control-Z. You should then be back in the shell. Give the fg command to return and bring the command back to the foreground again.


2

I've taken a brief look at the source code. The HTML parsing and rendering code is a core part of elinks, and while it appears to be somewhat modular, it is not a separate library. It might be possible to separate it, but not without a good deal of work. If you're curious, the src/README file provides an overview of how the various parts depend on each ...


2

Have a look on how screen or tmux do cut'n'paste. Both mimic cut'n'paste using cursor keys and some other command keys, so this will work wherever you can start screen or tmux. No real mouse is needed, will work via ssh too... Or... If you have physical access to that server's text console and a mouse is attached, read about gpm which will give you a mouse ...


2

The file (directory) is open. When you do rm it, the OS marks it as deleted without actually deleting it. In case you try to do cd into this directory from another shell instance, you will be denied the permission. After you cd out of this directory, the directory will actually get deleted.


2

The OS doesn't return that the working directory is 'dir1', the shell does. The shell keeps track of the current working directory, and the 'pwd' command you're running is a command built into the shell. The shell is not aware of the fact that your 'rm' command removed the directory. $ type pwd pwd is a shell builtin Try running /bin/pwd instead: $ ...


2

People usually use a pager like less to read such a long output: sshfs -h | less On less type H to show help. Q to quit. Note that you might occasionally need 2>&1 to see also additional output from stderr. For sshfs -h it has such an output so you'd better do that like this: sshfs -h 2>&1 | less Besides using a pager, on Linux text ...


2

Use gpm. You can install it with sudo apt-get install gpm Once that is finished, you will have a working mouse. Now you can cat the file that contains your data, select it and then paste it with the middle mouse button. Assuming, of course, that you have a mouse.


2

^=* means search for a line starting with zero or more equal signs. If you want lines starting with = just use ^=


2

How many colours are supported and how to change the foreground and background colour depends on the terminal. The terminfo database is usually there to help you come up with the right sequence. Most colour terminals support the ANSI colour escape sequences to change the foreground and background colours 0 to 7. That's: set foreground colour $n: printf ...


1

One option would be to used named pipes. Your application could write to the named pipes, and you could monitor the pipes in the same fashion that you're currently doing. You'd probably want to make your write operations to the pipe non-blocking so that if the pipe fills up it doesn't block the program execution. Note, however, with that you'd be loosing ...


1

The normal UNIX way to stream data from one application to another without saving it permanently is a pipe. In shell: data-producer | data-consumer You can always use named pipes for patterns more complex than a single producer emitting and a single consumer receiving: # Set up the pipes mkfifo /tmp/pressure.fifo mkfifo /tmp/temperature.fifo # Start the ...


1

Google image is your friend. That points to some archey python script. Not that I've managed to get anything out of it.


1

# dmidecode is a good beginning.


1

I used to use terminator a lot when I did network demos. It lets you create multiple windows and group some or all of the windows then you can have your key strokes go to all of the windows at the same time. You can use this to start separate instances at almost the same time, or enter the same command to different machines, etc.


1

It looks like you entered terminal in the configuration in the place where you should write the program name that should run inside the terminal window. Normally, that is a input field below the name ot the terminal profile you are editing. /bin/bash would be good, if you want to use bash normally. You can leave it empty, then a default is choosen - which ...


1

I've found solution here. In general: Run PuTTY Configuration. In the left pane, select Terminal, Features. Put a check mark next to "Disable application keypad mode". In the left pane, select Session. Save the settings.


1

You'll have spaces at the end of the line when selecting and copying from the terminal if the application displayed spaces at that spot. Applications may display spaces in order to erase what was there before. Terminals have commands to delete a whole line or delete characters to the right of the cursor; applications choose between that and displaying spaces ...


1

Copy & pasting from a terminal screen is never going to be fully reliable because it's dealing with screen output instead of original source material. If some applications echo text to the terminal in an unusual fashion and it results in the terminal not being able to guess what the original text was, there's probably not much you or the terminal can do ...


1

shw@shw:/tmp $ ls testdir/!(*/) & pidls=$! [1] 18453 shw@shw:/tmp $ shw@shw:/tmp $ cat /proc/18453/cmdline bashshw@shw:/tmp $ shw@shw:/tmp $ shw@shw:/tmp $ kill -9 18453 shw@shw:/tmp $ [1]+ Killed ls --color=auto testdir/!(*/) shw@shw:/tmp $


1

Using bash, this will remove all files that don't have another file with the same name but different extension: for f in *; do same=("${f%.*}".*); [ "${#same[@]}" -eq 1 ] && rm "$f"; done This approach is safe for all file names, even those with white space in their names. How it works for f in *; do This starts a loop over all files in the ...


1

According to the GNU Grep documentation: If the final byte of an input file is not a newline, grep silently supplies one. So, if you're using GNU grep, you should be able to use the beginning-of-line/end-of-line anchors (^ and $) as usual, even if you're not working on properly-formed plaintext files. grep '^.\{32\}$' fileA fileB


1

Here is a solution which will both unlockpt() a new pty descriptor and write its ptsname() to stdout for you. <<\C cc -xc - -o pts #include <stdio.h> int main(int argc, char *argv[]) { if(unlockpt(0)) return 2; char *ptsname(int fd); printf("%s\n",ptsname(0)); return argc - 1; } C Which just compiles a tiny ...


1

Use col -b (on Linux it's part of the util-linux package; in base system elsewhere). col filters out reverse (and half-reverse) line feeds so the output is in the correct order, with only forward and half-forward line feeds.



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