Tag Info

New answers tagged

0

#!/usr/bin/env xdg-open [Desktop Entry] Name=argus Exec=gnome-terminal -e "sh -c 'argus -h; bash'" TryExec=argus Type=Application Categories=System;Security;X-SecurityLab;X-Reconnaissance; This matches behavior most closely. It could be improved upon by someone who knows argus better than I


0

The problem is that scl enable devtoolset-1.1 bash creates a new bash shell. So when you put it in your .bashrc, it creates a new shell...which loads your .bashrc, which runs scl enable devtoolset-1.1 bash, which creates a new shell, which loads your .bashrc... Forkbomb! You probably want something like this in your .bashrc: if [ "$(gcc -dumpversion)" != ...


3

You don't need to force man's output via process substitution. Redirection works fine for it: man ls > tem.txt Even if you so use process substitution, remember to use quotes, otherwise the output will undergo splitting + globbing from the shell: echo "$(man ls)" > tem.txt


1

Running a program in the background by adding & at the end is like running an application minimized in Windows or Mac. And using the fg command is like restoring it back to the desktop. In comparison, when you press ctrl+z while a program is running will suspend its execution. Which means it will be stopped from completing what it is doing and sent to ...


1

Most commands issued from an interactive shell run in foreground. That basically means that you must wait for the executed command (or processus ) to stop before doing something else. For long/complex programs or scripts, the alternative is to run them in the background. This means that you can continue to work while the long program executes. The ampersand ...


0

in simple words, Every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen. $ls ch*.doc which list all the files in current directory, A background process runs without being connected to your keyboard. If the background process requires any keyboard input, it waits.The advantage of ...


1

Both WAV and FLAC formats are lossless, which means they do not lose any quality from an original music CD. WAV however is uncompressed, while FLAC uses a lossless compression mechanism (pretty much like a ZIP lossless compression) specifically designed for efficient packing of audio data. FLAC files can then be played with your favorite player, just like ...


0

After hours of searching: Comment out the *.emerg line or change it to *.emerg /var/log/messages etc


0

If you are using zsh then you can take advantage of the power of MULTIOS feature, i.e. get rid of tee command completely: uname >file1 >file2 will just write the output of uname to two different files: file1 and file2, what is equivalent of uname | tee file1 >file2 Similarly redirection of standard inputs wc -l <file1 <file2 is ...


4

No, it's not correct. I have no idea what the \1{3} is supposed to be but that's what is causing you problems. If you want to find lines that contain three repeated characters followed by three other repeated characters, you can use this: grep -E '([a-z])\1{2}([a-z])\2{2}' The \1 refers to the first captured group. You can capture groups by using ...


1

Functions are perfectly suitable for this purpose. For example: cmd() { echo $* >> /path/to/file'; } This is on one line, just like an alias. But it can take parameters.


4

I find uconv (in icu-devtools package in Debian) useful to inspect UTF-8 data: $ print '\\xE9 \xe9 \u20ac \ud800\udc00 \U110000' | uconv --callback escape-c -t us \xE9 \xE9 \u20ac \xED\xA0\x80\xED\xB0\x80 \xF4\x90\x80\x80 (The \xs help spotting the invalid characters (except for the false positive voluntarily introduced with a literal \xE9 above)). ...


1

Python has had a built-in unicode function since version 2.0. #!/usr/bin/env python2 import sys for line in sys.stdin: try: unicode(line, 'utf-8') except UnicodeDecodeError: sys.stdout.write(line) In Python 3, unicode has been folded into str. It needs to be passed a bytes-like object, here the underlying buffer objects for the ...


3

If you want to use grep, you can do: grep -av '^.*$' file in UTF-8 locales to get the lines that have at least an invalid UTF-8 sequence (this works with GNU Grep at least).


9

I think this should do it: tar -xzf file.tar.gz -C ~/locationX folder1 -C ~/locationY folder2 The -C option means to change to the specified directory before doing the extraction. Specifying filename arguments after the tarfile name restricts the extraction to just those files or directories. And you can repeat this -Changing directories as you do. Note ...


-2

sudo kill -9 $(job -p) This will work


0

After installing the tree command, just type $ tree If you are using Debian / Mint / Ubuntu Linux, type the following command to install the tree command: $ sudo apt-get install tree The option -L is used for specifying the maximum display level of the directory tree. The tree command does not only count the number of files, but also the number of ...


0

Simply you should try this echo 3 > /proc/sys/vm/drop_caches but you one is also working with me Same situation here but works fine [root@I-IDS ~]# w 20:56:35 up 4:03, 2 users, load average: 0.00, 0.00, 0.11 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty4 - 16:55 3:48m 0.25s 0.25s -bash root ...


2

I like using an easy to use unix command line bash script called VCS - Video Contact Sheet. Their official page: http://p.outlyer.net/vcs/ Its a lot easier to use even easier than a GUI ''It is a bash script meant to create video contact sheets (previews) aka thumbnails or previews of videos. Any video supported by mplayer and ffmpeg can be used by this ...


2

String interpolation causes this. There are a number of ways to selectively prevent this from happening. The bash hackers wiki has some good examples, though the specifics may vary if you're not actually using bash. In short, you can prevent interpolation with single quotes, or you can escape the characters. [me:~/work]$ export foo=bar [me:~/work]$ echo ...


0

For OS X you can use this bit of applescript: activate application "Firefox" tell application "System Events" to keystroke "r" using command down


1

Let's use AWK! This function lists the frequency of each word occurring in the provided file in Descending order: function wordfrequency() { awk ' BEGIN { FS="[^a-zA-Z]+" } { for (i=1; i<=NF; i++) { word = tolower($i) words[word]++ } } END { for (w in words) ...


1

In some case, wmctrl could help. This utility is compatible with a lot of windows managers. wmcrt -m should display the name of the currently used window manager.


0

If I remember correctly from the top of my head, the following too are identical: $ ./script and $ source script So using the ./ "command" will in fact invoke source under the hood, which on its part is a bash builtin command. Or, in another interpretation they might be called aliases of each other. I think that will answer your question as well in ...


4

If you have two zip files a.zip and b.zip in your current directory, then $ cp *.zip destination/ expands to $ cp a.zip b.zip destination/ The semantics for cp is to copy both a.zip and b.zip to destination. If you type $ cp \*.zip destination/ it simply "expands" to $ cp '*.zip' destination/ i.e. it will try to copy a single file named "*.zip" ...


2

On the contrary, unzip does too much. cp doesn't need to parse the filenames, all it needs to do is loop over them. Unzip, on the other hand, needs to see if an argument is a wildcard, check the directory listing to see what matches the wildcard and then loop over those. And note that the shell already is capable of matching and expanding wildcards, so ...


1

I wound up up creating a variant on swalog's answer. With his you had to wait X seconds for the first iteration, I'm also running my in the foreground so.. ./foo.sh;while sleep 1; do (./foo.sh) ; done


1

A few things: As derobert notes, the language and the Unix platform are case-sensitive. The then keyword is used only with an accompanying if. To simply run on command after another, either: Keep them in different lines: diff workfile1.txt workfile2.txt wc workfile1.txt workfile2.txt Or separate with semicolons: diff workfile1.txt workfile2.txt; wc ...


3

NAME chvt - change foreground virtual terminal SYNOPSIS chvt N DESCRIPTION The command chvt N makes /dev/ttyN the foreground terminal. (The corresponding screen is created if it did not exist yet. To get rid of unused VTs, use deallocvt(1).) The key combination (Ctrl-)LeftAlt-FN (with N in the range 1-12) usually has a similar effect.


0

Yes, you can do this with a quick script: #!/bin/bash klist || kinit ssh user@host Put this in your PATH and run it instead of ssh. This works by using the klist utility. If you have no active tickets, then klist will fail and kinit will be run. If you have an active ticket, then klist will succeed and kinit will not be run. I haven't tested this ...


1

The behaviour you're looking for is a special case: cp -R [-H|-L|-P] [-fip] source_file... target [This] form is denoted by two or more operands where the -R option is specified. The cp utility shall copy each file in the file hierarchy rooted in each source_file to a destination path named as follows: If target exists and names an existing ...


1

Also this(for slightly shorter and more readability): grep -Ff <(awk '{print $1}' Cell_cycle.txt) filename.fasta


1

Use process substitution <(): fgrep -A 1 -f <(cut -d " " -f 1 Cell_cycle.txt) filename.fasta


0

If you mean writing a program that allows using the command to control your program after it went to the background, you can use IPC mechanisms such as sockets and dbus. Your program will go into the background and acts as a "server" if no other arguments are given. Otherwise, it will acts as "client" and try to communicate with the "server". The client ...


0

I'm not totally sure what you mean by "communicating with it" - but if you mean start/stop, there are a few easy ways to "hack" this type of behavior. Option 1: Code your application to run natively in the background. For instance, python has a daemon module where you can move your process into a service/daemon like state. Here's an example in python: ...


1

To expand parameter, arithmetic and command substitutions (and not aliases and other forms of expansions), you could do: my-expand() BUFFER=${(e)BUFFER} CURSOR=$#BUFFER zle -N my-expand bindkey '\e^E' my-expand (it would have similar limitations and could be almost as dangerous as bash's one though).


1

You can set up compinit to expand parameters in your ~/.zshrc: zstyle ':completion:*' completer _expand _complete autoload -Uz compinit compinit This is a minimal setting, if you have compinit already enabled, it should be sufficient to add _expand to the settings of completer There is also the expand-word widget that is by default bound to ^X* (Ctrl+x ...


0

You can make simple script in home folder(or any folder other than the folder which contains the files you are intending to move). The script will be like this: #!/bin/bash for var in ./* do if [ -f "$var" ] then mv "$var" /home/user/"$var".backup1 fi done run this script inside the folder from which you are intending to move files i.e. by cd <the ...


1

The simplest route, IMHO, is to use a variable: a=file.csv; mv "$a" ~user/"$a"_backup You can avail of tab completion with variables, both while setting them and while using them.


0

Another solution. A little crude, but this is going to work if all the original files are going to have the extension .csv and if you want to move all the .csv files from the current directory. for i in *.csv; do mv $i /home/user; rename .csv .csv_backup1 /home/user/*.csv; done Just change the 'user' for each users when needed.


1

In bash, you could try the following: Type mv file1. Press Ctrl-w enough times to delete file1. Press Ctrl-y to paste file1 back. Type /home/user/. Press Ctrl-y to paste file1. Type the rest: _backup


2

You could use a bash or ksh function added in your shell rc file : mymv(){ echo mv "$1" "$2/${1##*/}_$3"; } mymv file.csv /home/user backup1 remove the echo when tests are done


0

I prefer the following command line: $ du -s -m -x * | sort -n Breaking it down, du shows disk usage; -s says print the total for each argument (each item in the current directory), -m says show the size in Megabytes. This makes it easier for sort to work; sort doesn't really understand the -h output. The -x ignores other filesystems; this is useful ...


0

I had the error as well connecting with my laptop to a kvm guest on a kvm-host until I added /sec:rdp /usr/local/bin/xfreerdp /f /rfx /cert-ignore /v:myhostip /u:mywindowsuser /p:mypassword /sec:rdp


0

I had a similar issue, but the answers on this page weren't enough. I found the following command to be the most useful for the listing: du -a / | sort -n -r | head -n 20 Which would show me the 20 biggest offenders. However even though I ran this, it did not show me the real issue, because I had already deleted the file. The catch was that there was a ...


1

cd INPUTDIR find . -name \*1.fastq.gz > list1 find . -name \*2.fastq.gz > list2 The paths in the "list" files will be relative to the current directory. If you want absolute paths, use find "$PWD" -name \*1.fastq.gz > list1


0

If you can live with a perl solution: perl -pe 's/\r";"/";"/g' foo.csv >foo_r.csv


1

It is important to understand that sed works on a line by line basis. What sed does is basically : read a line into its buffer without the newline, execute your commands on the buffer, print the buffer (provided you haven't specified the -n flag), read the next line into its buffer, etc. So to merge two lines with sed requires that you explicitly force sed ...


4

There is a --max-size option to rsync which will exclude files from over a certain size from being copied from one directory to another. From the man page; --max-size=SIZE This tells rsync to avoid transferring any file that is larger than the specified SIZE. The SIZE value can be suffixed with a string to indicate a size multiplier, and may be a ...


2

You need double quotes to make the shells don't perform field splitting: XX="$(ls -l)"; echo "$XX" But it's not good to use echo with variable that you don't know its content, you should use printf (read this answer) instead: XX="$(ls -l)"; printf '%s\n' "$XX"



Top 50 recent answers are included