New answers tagged

0

I don't think you can use a signal. But Xpdf accepts synthetic events, so it's easy to programmatically type r into the window. If you know the PID of the xpdf process: xdotool search --pid 1234 key r If you know the name of the file that Xpdf is displaying, you can match the window's title: xdotool --name 'Xpdf: foo.pdf' key r There's a small risk of ...


0

It is the command-line interface of GRUB. If you choose the command-line menu option, or if the configuration file was not found, then GRUB drops to the command-line interface. From GRUB Manual: The command-line interface provides a prompt and after it an editable text area much like a command-line in Unix or DOS. Each command is immediately executed ...


2

Looks like one of your previous attempts to change the /etc/passwd file has left some rubbish in the lock file. That lock file prevents multiple updates that would cancel each other out. If you are the only one using that system, remove the file /etc/passwd.lock and try again.


0

So if you wanted to get just the time value without the ms label: HOST="127.0.0.1" PING_MS=`ping -c1 "$HOST" | /usr/bin/awk 'BEGIN { FS="=" } /time=/{gsub(/ ms/, ""); print $NF; exit}'` This gives me: 0.058 Now, if we wanted to test if time>=50.0, we could use awk for this, too, since POSIX sh itself can't compare decimal numbers: if echo ...


0

#from outside mv sample_dir1/sample_dir/ . mv sample_dir1/ sample_dir/ would make a little bit of sense.


1

I think that ifconfig is not handling wireless stuff like ESSID, channel and key. Take a look to iwconfig instead. http://manpages.ubuntu.com/manpages/vivid/it/man8/iwconfig.8.html


0

Per grep manual: -v, --invert-match Selected lines are those not matching any of the specified patterns. If you supply only one line abc and tell grep to select only lines not matching a you get an empty output and return code equal to 1. If you supply three lines a, b, and c and tell grep to select only those not matching a you get b and c in ...


4

Present (or Current) Working Directory Does the command pwd in a shell script return the directory the shell script is in? No. Firstly, by definition, no shell script or shell command returns anything other than a numeric exit status between 0 - 255. That's axiomatic, but not generally not what people mean when they ask these types of questions. ...


3

There is this concept called cwd that every running process keeps track of. Or better worded: the kernel keeps an idea of the cwd of each process. That could be read with (for a system with /proc): readlink /proc/$PID_of_PROCESS/cwd And for the running shell (of which its PID should be $$): $ readlink /proc/$$/cwd The shell keeps track of the same ...


0

It returns directory from where it is called/run from & not where the script is ! Here is try.sh : echo "The current working directory: $PWD" This output will make more clear : [akarpe@ADM-PROD-OMNI ~]$ sh try.sh The current working directory: /mnt/home/akarpe [akarpe@ADM-PROD-OMNI ~]$ sh try/try.sh The current working directory: /mnt/home/akarpe ...


17

There are three independent "directories" at play here: your current shell's current working directory, the shell script's current working directory, and the directory containing the shell script. To demonstrate that they are independent, you can write a shell script, saved to /tmp/pwd.sh, containing: #!/bin/sh pwd cd /var pwd You can then change ...


0

Use rtmon to record network interface changes and then parse its output as needed.


1

The recode program can do this quickly even for large files, either frequency statistics either for bytes or for the characters of various character sets. E.g. to count byte frequencies: $ echo hello there > /tmp/q $ recode latin1/..count-characters < /tmp/q 1 000A LF 1 0020 SP 3 0065 e 2 0068 h 2 006C l 1 006F o 1 0072 r 1 ...


4

I found a similar method. On first terminal: $ tty /dev/pts/0 $ <no need to run any command here, just see the output> On second terminal: $ ls > /dev/pts/0 Now you get the output on first terminal


-4


14

If both terminals belong to the same user, you can send your output to the virtual device that is used as the particular terminal's tty. So you can use the output from w, which includes the TTY information, and write directly to that device. ls > /dev/pts/7 (If the device mentioned by w was pts/7) Another option is to use the number of a process that ...


8

You can use write command. As @MelBurslan commented, if write permission is off, first execute: $ mesg y From man mesg OPTIONS y Allow write access to your terminal. Usage of write: $ write username tty e.g. Send ls output to other terminal. $ w USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT user :0 :0 ...


0

Using ksh or bash -O extglob or zsh -o kshglob -o nobareglobqual: $ echo $KSH_VERSION Version AJM 93u+ 2012-08-01 $ ls abc_+([0-9]).txt abc_160101.txt [0-9] is a range expression matching any characters between 0 and 9. Here it is the PATTERN. +(PATTERN) matches one or more occurrences the PATTERN.


0

In a Bourne-like shell: set abc_* first_file=$1 date=${first_file#*_} date=${date%.*} Note that if there's no matching file, $first_file will be abc_*. The order is based on the collation order in the current locale. Note that in ls abc_*, it's the shell that expands the abc_* glob into a sorted list of file and directory names passed as arguments to ...


2

As for software for doing remote Windows automation tasks from the Unix/Linux side, I am aware of: Ansible - devops automation framework Rundeck - web based Java automation framework putty - pscp tools, for talking SSH on the Windows remote side cygwin - cross-compiled GNU tools framework for Windows Win32-openSSH - Microsoft´s port of OpenSSH freeSSHd - a ...


0

Single quotes '' are used to indicate the start and end of the characters. -g flag in sort compare according to general numerical value. -r option make the output sorted from highest to lowest, since the default output of sort is lowest to highest. -k option is used if we want to sort on the column or word position in lines of text file.


3

You've got most of the technical details, but I think you're missing the semantics of the whole thing. The single quotes in '^d' keep whatever shell runs that pipeline from treating characters in the regular expression (which is '^d') as "special". For example, $ is the regular expression meaning "end of line". Shells also use $ to mark the next token as a ...


0

WordGrinder lets you view .odt files (text content only, naturally) in the console:


1

I did df -a and saw root was 100% in use. so then I tried: du -ak / | sort -nr | less to get the directories holding the most space. while that was attempting to run, it crashed, saying "/var/tmp is full" so I went into /var/tmp, and deleted everything. once I did that, I was able to print again. for giggles, I ran du -ak / | sort -nr | less again, to ...


0

cat /dev/urandom | tr -dc 'a-fA-F0-9' | fold -w 8 | head -n 1 This will generate an 8 digits long hexadecimal number.


0

If your epoch time is in milliseconds instead of seconds, remove the last three digits before passing it to date -d: $ date -d @1455086371603 Tue Nov 7 02:46:43 PST 48079 #Incorrect This gives incorrect data. Remove the last three digits. $ date -d @1455086371 Tue Feb 9 22:39:31 PST 2016 #Correct after removing the last three digits. You may ...


0

I have another perhaps simpler approach to cleaning up old print jobs. Instead of finding a way to convert the abbreviated time stamps on the print jobs, it's easier to use the find command to accomplish the task of deleting old print jobs fitting a certain criteria. For example, if you want to find print jobs older than 4 days: find /var/spool/cups -name ...


2

You are missing one pipe | character. Try: sort myfile |uniq -u|tee newfile.txt If this is not working, please provide the error message you are getting. By the way, this command uniq -u eliminates all lines which have duplicates. If this is your intention, that is fine. But if you want to see one of the duplicate lines, you need to drop -u for the uniq ...


4

Yes, it is provided by GRUB. The GRUB command shell is just as powerful as the shell. You can use it to discover boot images, kernels, and root filesystems. When you're at the grub> prompt, you have a lot of functionality similar to any command shell such as history and tab-completion. The grub rescue> mode is more limited, with no history and no ...


1

You can use the read shell builtin: while IFS=" " read -r value1 value2 remainder do ... done < "input.txt" Extra fields, if any, will appear in 'remainder'. The shell's default IFS (inter-field-seperator) consisting of white space characters will be used to split each line into its component fields.


0

In version 2.1.2, compiled from source, it's "Effect->Compressor".


0

You can get information using the command stat Example: stat index.htm ==> File: `index.htm' Size: 17137 Blocks: 40 IO Block: 8192 regular file Device: 8h/8d Inode: 23161443 Links: 1 Access: (0644/-rw-r--r--) Uid: (17433/comphope) Gid: ( 32/ www) Access: 2007-04-03 09:20:18.000000000 -0600 Modify: 2007-04-01 23:13:05.000000000 -0600 Change: 2007-04-02 ...


1

Instead of pasting into the terminal, have the command read from the clipboard. You can use xclip or xsel to print the clipboard content (or conversely write their input to the clipboard). xsel | perl # automatic selection (click+drag, middle click) xsel -b | perl # manual selection (Ctrl+C, Ctrl+V) This only works if the shell in the ...


2

Reinstalling the entire system would be overkill, if you ran the command as non-root user. Even if you can't/won't restore all settings and files immediately, it would be far easier to create another user on the system and work as that user. You can still move over settings, data files, etc. from the old account as you find the need. (Keep in mind though ...


1

Workaround: Open additional pdf files either using the absolute path names or relative path names to the initial pdf file. So for example okular foo.pdf & okular ../foobar.pdf and okular foo.pdf & okular /the/complete/absolute/path/to/foobar.pdf both work. //Update: To automate the workaround, this function can be added to ~/.bashrc. It ...


0

Command piping you can use anywhere you feel that output of first command can be fed as input to next. Examples. With text files you can pass the text file to grep to find particular lines of text. Then you can pass the output to sed or awk to modify or print certain part of line. cat example txt | grep {some_line} | awk {some_command} Working with ...


0

Pipes work best with filters and translators find /usr/bin/ | #produce sed 's:.*/::' | #translate: strip directory part grep -i '^z' | #filter : select items starting with z xargs -d '\n' aFinalConsumer #consume This way, the data can flow from one program to the next one bufferful and at no point ...


0

execute this one in any directory you want have an sorted analyse for folder size (then scroll down with END key): du -m| sort -n| less Sortiert nach Ordnergrösse


1

In addition to the "solution/work-around" by Jeff Schaller , the proper solution seems to be to make the environment aware of copy-paste, both from sender side and from receiver side, which is known as "bracketed paste mode". From https://cirw.in/blog/bracketed-paste , here is a short snippet to explain a little more : In summary: Enable ...


3

You can do: grep -o '[^ ]*\.swf' file.txt [^ ]* matches zero or more non-space characters \.swf matches literal .swf Example: % grep -o '[^ ]*\.swf' file.txt example.swf example2.swf example3.swf


7

With GNU grep: grep -o '\b\w*\.swf\b' file Output: example.swf example2.swf example3.swf \b: a zero-width word boundary \w: word character \.: match one dot See: The Stack Overflow Regular Expressions FAQ


3

First step Replace spaces with line ends using sed Second step Filter the output using grep Example sed -e s/\ /\\n/g file | grep .swf


2

This is not an answer, but maybe it's an acceptable work-around: alias p='perl; echo hit control-d again; cat > /dev/null' Then, if your perl script exits prematurely, you'll harmlessly paste the remainder to /dev/null; if the perl script succeeds, you'll see your friendly reminder and hit control-d to exit the cat catcher.


0

This works with your sample awk ' NR==FNR {patt[$0]; next} $0 in patt {getline; getline; getline; prev=$0; next} {print prev; prev=$0} END {print prev} ' fileA.txt fileB.txt You have to keep all of fileA in memory, but you only need to remember one line at a time from fileB


0

Next code is not optimal (because it have to read FileB.txt twice) but hope it can be more quick then awk comm --nocheck-order -23 FileB.txt <(grep -B1 -A2 -Ff FileA.txt FileB.txt) With new GNU sed command e you can try (for memory saving) sed + grep: sed 'N;h;s/.*\n//;s/.*/grep -xF "&" FileA.txt/e;/./{N;N;d};x;P;D' FileB.txt


0

you can try the same windows like fc command in Unix and Linux i.e. diff <file_new> <file_old> command. Line with +++ or --- in front of them have changed and one with no +'s and -'s haven't changed Lines with - sign are removed from the new file however they existed in old version Lines with + sign are added from in new file however they ...


0

Note: No error checking. Also, assumption is that the input in 2nd file follows the pattern mentioned exactly. awk 'NR== FNR {a[$0] = $0 ; next } {if (!($0 in a)) {b[count++] = $0; } else {count--; if (count > 0) delete b[count];getline;getline; }} END {for (i=0; i<count; i++) print b[i] }' 1 2 inputs are in 1 and 2 1 ATGCATGC GGGGGGTT TTTTT AAAA ...


3

Depending on the user you are using, you may need to type su - or sudo first to get root privileges. Type lsblk: > lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111,8G 0 disk ├─sda1 8:1 0 1020K 0 part ├─sda2 8:2 0 41G 0 part ├─sda3 8:3 0 11G 0 part ├─sda4 8:4 0 19G 0 part / ├─sda5 8:5 0 ...


0

There are a couple of approaches I can think of. First, if you don't mind having multitail close when the longer running command finishes, you can pipe the shorter running command to it and display stdin: short-running-command | multitail -s 2 -l "long-running-command" -j Second, you can add a long delay after running the commands: multitail -s 2 -l ...



Top 50 recent answers are included