date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,633,012,780,000
Today I noticed I was getting an error from a tool which verifies its file descriptors on startup. The fact is that I get an extra pts connection: # In one console I start `cat` linux $ cat >/tmp/test # In another console I search for `cat`'s process ID linux $ ps -ef | grep cat alexis 34462 25012 0 11:58 pts/17 ...
RVM opens a new file descriptor to whatever standard error is currently connected to when it starts. Thus, in an RVM environment, file descriptor 6 is the RVM log output. This way RVM can log to the same place by writing output to file descriptor 6, regardless of whether standard error has been redirected. The file de...
When I start a process on my computer, I see a file descriptor number 6 open, what is that descriptor for/about?
1,633,012,780,000
I am using zsh 5.4.2. The function that is causing issue is: function zp () { zparseopts -E -watch:=o_watch -show=o_show echo "show : $o_show" echo "watch : $o_watch" } Output: $ zp --show --watch "Watching" show : --show watch : --watch Watching $ zp --wat...
For comparison, I'm pretty sure that's how the GNU C function getopt_long also works, e.g. with GNU ls: $ ls --sort --foo ls: invalid argument ‘--foo’ for ‘--sort’ Valid arguments are: ... If you made the argument to --walk optional, zparseopts would take --watch --show as two arguments: In all cases, option-argumen...
If no argument is given to mandatory option, zparseopts takes next option as the argument
1,633,012,780,000
I would like to search for text with accents in files. I know that I can use grep for searching regular text: grep -rnw './' -e 'KORONA' ...but it doesn't work for words with accent characters, like KORONAVÍRUS, obmedzená. Any recommendation?
If the encoding of all the files is the same, you just need to write the searched sentence in that encoding. That brings up two possible conditions: The encoding on the command line (or where the command is executed) (probably set by one of the locale variables LC_*) is the same as the encoding of all the files, then...
Search text in files with accent characters
1,633,012,780,000
I have a tiny script which generates aliases for the execution of flatpak packages (to make flatpaks somehow usable from the command line). When I run this command by hand, everything works fine. But instead of always executing this command by hand after each flatpak install/update/remove I want my script to be execut...
You can create an alias and add that to your .bashrc: alias flatpak='flatpak_(){ flatpak "$@" && ~/my_script.sh; }; flatpak_' To only execute my_script if first argument was install or remove: alias flatpak='flatpak_(){ flatpak "$@" && [[ "$1" = install || "$1" = remove ]] && ~/my_script.sh; }; flatpak_'
How to execute a command/script after a specific command was executed?
1,633,012,780,000
We have a dedicated server with OVH. We can access the server via SSH and WHM Cpanel. We want to increase the size of the /dev/sda2 partition. It is only 20 GB. And running out of space frequently (every other day). We want to increase the size to at least to 50GB. How can we do it. Can you please provide technical ...
In Linux nearly everything is possible. The main question is, what is the reason, and what is the goal. Your sda disk has two main partition: sda2 as / (root of the filesystem) and sda3 as /home/ . There would be some swap partition (may be sda1), too. In such case, you cannot simply do any repartitioning, without st...
How to increase /dev/sda2 partition - OVH Server
1,633,012,780,000
For some reasons my Debian is broken and boots into a terminal based UI instead of the desktop. Where can I find my USB device storage directory in this terminal? Edit: It's not under /media.
As mentioned in the comments it must be under /media directory but it isn't, cause it's not mounted. It's possible to mount USB drive in the following way: sudo mkdir /media/usb-drive sudo mount /dev/sdb1 /media/usb-drive/
Access USB device storage via terminal
1,633,012,780,000
I am very new to bash, I don't even know if what I want is possible. Sorry in advance if unknowingly I am asking for too much and it isn't possible. I execute many different bash scripts for testing and learning process too frequently after doing small edits. It's really annoying to type the whole command over and ...
Create alias in your ~/.bashrc file: alias script1='su -c sh /sdcard/downloads/script1.sh' The alias will then be available in the next shell session that your start.
How to assign a word to execute a particular command [duplicate]
1,633,012,780,000
I am sorry if my question is more a typographical error, but I have been trying to sort this out for a while now and sadly, I cannot get this to work. Perhaps I should use the sed command, but I haven't figured out how to specify a column in sed and despite being a beginner, I have a bit more experience with the awk c...
$ perl -MText::CSV=csv -e ' $csv = Text::CSV->new(); while(my $row = $csv->getline(ARGV)) { $row->[13] = "NA" if ($row->[13] eq ""); $csv->say(STDOUT, $row); };' input.csv Note that perl arrays begin from 0, not 1 - so the 14th field is element 13 of the $row arrrayref. employee_number,employee_login,is...
AWK Command - Edit Blank "Cell" in CSV to Text Value
1,633,012,780,000
I want to print the output of docker stats to file. For example, I am running: docker stats --format "{{ .Name }},{{ .MemUsage }},{{ .MemPerc }},{{ .CPUPerc }}" > /home/test.txt However, since the normal output of docker stats is on one line which is updated, in the file I have the clear character (^[[3J^[[H^[[2J) pr...
You can pipe it through ansifilter: docker stats --format "{{ .Name }},{{ .MemUsage }},{{ .MemPerc }},{{ .CPUPerc }}" | ansifilter > /home/test.txt Notice that /home/test.txt will contain multiple lines. It will look something like this: alpine,656KiB / 7.476GiB,0.01%,0.00% alpine,656KiB / 7.476GiB,0.01%,0.00% alpin...
Print to file without clear character
1,633,012,780,000
Actually I am intending to create a shell script executing which should delete particular files/folders continuously say every 5 seconds which is continuously being generated by a application [ Below data being used is a dummy so that it becomes easy to understand and probably help others too in general ] Target App ...
Here is a short bash script I came up with. Note you will need to replace logger\.sh in the grep statements with the name of the process that you want to monitor. In this case it is checking for a process named "logger.sh" and grabbing the PID. #!/bin/bash pid=$(ps aux | grep "logger\.sh" | head -n 1 | awk '{print $...
How to create a shell script to delete a particular file in loop [closed]
1,633,012,780,000
| folderA1 | fileA11, fileA12, ... folderA | folderA2 | fileA21, fileA22... | ... | ... I want to make a copy of it represented as: | folderA1 | folderA11, folderA12, ... folderB | folderA2 | folderA21, folderA22, ... | ... | ... The original folderA (and it's structure) r...
You could cd into folderA and run the command from there: cd folderA find . -type d -o -type f -exec bash -c ' for path; do mkdir -p "/path/to/folderB/${path/file/folder}"; done ' bash {} + The parameter expansion ${path/file/folder} renames the each fileXY to folderXY. If every folder contains files, you can remo...
Create a folder for each file in a folder without the folder itself
1,633,012,780,000
I know I could use something like ncurses, but I don't want to include that dependency in my project. I'm looking for a way to clear all the output my program generated at a certain point, so I can show more information without flooding the screen. This is for a program written in Rust. There are libraries used to han...
If you have a terminal compatible with xterm you could try switching to an alternat(iv)e screen with Termion: use termion::screen::AlternateScreen; use std::io::{Write, stdout}; fn main() { { let mut screen = AlternateScreen::from(stdout()); write!(screen, "Writing to alternat(iv)e screen!").unwra...
How to clear all (and only) my program's output from the terminal
1,633,012,780,000
I am trying to grep a list of strings listed in 7253.txt which looks like this: rs11078372 rs1124961 rs11651880 rs11659047 rs1736209 using: grep -o -f 7253.txt *.logistic > result.txt from multiple files *.logistic. The files are on larger size and this grep command takes forever. .logistic files look like this:...
Perhaps you want awk ' NR == FNR {ids[$1]=1; next} $3 in ids {print $3, $12} ' 7253.txt *.logistic > result.txt
How to parse strings from a file in multiple other files?
1,633,012,780,000
I'm having a list of strings (sorted IP address ranges) like this: 10.100.0.0-10.100.255.255 External: 2.2.2.2 10.120.0.0-10.255.255.255 External: 2.2.2.2 10.0.0.0-10.255.255.255 External: 3.3.3.3 192.168.160.1-192.168.160.255 External: 3.3.3.3 and so on.. How can I group these by the last string of each line so that...
Remember the last external ip in a variable. If the new ip is different, print the new one. Then print the ip range. #! /bin/bash last_ip="" while read range _e ip ; do if [[ $ip != "$last_ip" ]] ; then printf '\nExternal: %s\n' "$ip" fi printf ' %s\n' "$range" last_ip=$ip done < "$1"
group list by last string of each line
1,633,012,780,000
I installed /bin/sh: wkhtmltopdf /usr/bin/ directory. However when I try to run the program by entering /usr/bin/wkhtmltopdf to shell I receive an error /bin/sh: /usr/bin/wkhtmltopdf: not found. It works, however, If I enter sh /usr/bin/wkhtmltopdf. Why is that and how can I fix it? The permissions are ls -l: -rwxr-xr...
As indicated by ldd output, this wkhtmltopdf binary is built against glibc, the GNU C library: libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f88720cc000) Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by wkhtmltopdf) The libc library implements the C standard library functions, as...
/bin/sh: /usr/bin/wkhtmltopdf: not found
1,633,012,780,000
There's an auto generated file on a remote location that is constantly changing, I can only view the remote file via ssh user@ip cat luckyNumbers it tells me today's lucky numbers and also passes along a secret encrypted message. Today's lucky number are 1 2 3 asdsa@!#SAxAaas 21gv3sad ASD@!# My goal is to redirec...
Here are a few ways to write line 2 of stdin to a specific file while sending all other lines to stdout. Using sed: ssh remotehost cat luckynumbers | sed -e '2 { w luckynumbers.txt d }' | decoder Using awk: ssh remotehost cat luckynumbers | awk 'NR == 2 { print > "luckynumbers.txt" } NR != ...
Partial Redirection with additional Piping
1,552,746,248,000
I am trying to figure out a solution for unix based systems (maxOS, Linux) to zip unknown amount of packages, ideally without requiring users to install any additional third party software. I have folder structure like this MyProject /packages /custom-modules /Module1 /ios /src /Mod...
Starting from the MyProject/packages/custom-modules directory, this one-liner can do the job: for module in * ; do cd "$module/ios/" && zip -qr "$module.zip" src/ && cd - &> /dev/null ; done The idea here is get all the module directory names using the wildcard/glob. Then for each directory, change to the 'ios' subdi...
Using terminal to zip unknown amount of packages with dynamic names
1,552,746,248,000
I have two regular expressions i.e. command1 and command2 where i need to combine both expressions into a single expression using | for that command1 output should be passed to next expression. command1: grep 0x017a /sys/bus/pci/devices/*/device | cut -d/ -f6 >> Output : 00:00:01 command 2: head -n1 /sys/bus/pci/devi...
To use the output of one command as argument of the second command the mechanism of command substitution $() can be utilized. For example: Instead of $ whoami jimmij $ ls /home/jimmij/tmp file1 file2 you can do $ ls /home/"$(whoami)"/tmp file file2 In your specific case the single command become head -n1 "/sys/bus...
How to use regular expression result into another expression
1,552,746,248,000
I have a very large wordlist. How can I use Unix to find instances of multiple words fitting specific character-sharing criteria? For example, I want Words 1 and 2 to have the same fourth and seventh characters, Words 2 and 3 to have the same fourth and ninth characters, and Words 3 and 4 to have the same second, four...
It's difficult to avoid processing the file list many times, but once for each rule should be enough. The main processing would be over the words, repeated 10 times, whilst extending possible "word lists" where for each list, the i:th word matches the i:th rule with respect to that list. Each word is added to extend a...
Filter different identical characters in multiple words
1,552,746,248,000
I have 20 Files in a folder. 10 files naming pattern is PTT-20190118-WA0010.wav and other 10 files naming pattern is PTT-20190118-WA0010_s.wav. How to delete files with "PTT-20190118-WA0010.wav" pattern with single command ?
If you don't have any other matching files you can use rm PTT-*[0-9].wav or even rm *[0-9].wav assuming all file names without _s end with a digit before .wav. I suggest to try with echo instead of rm first or use rm -i to get a confirmation request for every file to avoid accidentally removing the wrong files.
Removing files in a folder with specific pattern
1,552,746,248,000
In using the wget command below, $ wget \ --recursive \ --no-clobber \ --page-requisites \ --html-extension \ --convert-links \ --restrict-file-names=windows \ --domains grantmlong.com \ --no-parent \ grantmlong.com/teaching/index.html I have been trying to download al...
After some more searching, I found a (hacky) solution to the problem of downloading an archive of reveal.js slides. On the codimd github, the user "zeigerpuppy" posted the following response: I have found a way to save an archive of a slide presentation built with codimd. I had some trouble getting wget to pull th...
Can wget download reveal.js image assets?
1,552,746,248,000
Let's say I have a (Python3) script of my own named myscript; for various reasons, myscript (not myscript.py) is stored in a sub-directory named bin : mydir/ mydir/bin/ mydir/bin/myscript -rwxr-xr-x myscript begins with the usual shebang line, namely : #!/usr/bin/env python3 When I'm in mydir/, I call my scri...
@Kusalananda mentioned that it's possible your script is calling myscript using system(). When you call with system I would guess the containing directory of myscript is not in the $PATH variable of the shell at that point, so you would need to pass the full path of myscript, not the relative path.
program called twice from the command line [closed]
1,552,746,248,000
I have two projects named project1 and project2 with identical file trees as follows. project1/, project2/ . ├── src │ ├── index.html │ ├── main.js │ ├── normalize.js │ ├── routes │ │ ├── index.js │ │ └── Home │ │ ├── index.js │ │ └── assets │ ├── static │ ├── store │ │ ├── cr...
In a single line -- not a single command -- calling diff once for each: while IFS= read -r filename; do diff project1/"$filename" project2/"$filename"; done < files-to-compare.txt This reads the files-to-compare.txt file line-by-line, ensuring that nothing gets in the way of reading the entire line, then calls diff w...
How to see which files are identical given a list of files in two projects
1,552,746,248,000
I'm using KDE and I want to change system sleep timeout. It should be a part of a system bootstrap script (i.e. I want to automate it), so I'd like to know how can I manipulate KDE configs from command line. I've found this question, but the answer only works inside an X session, and I'd like to execute the script ove...
You did not state which version of KDE you are using. User config files have been moved around between releases. In earlier releases, a lot was in ~/.kde or ~/.kde4 while more recently ~/.config is the standard directory. With plasma 5.13 from KDE Neon, Power devil uses ~/.config/powermanagementprofilesrc. A general s...
How to edit KDE suspend settings via command line, without X session?
1,552,746,248,000
The command pstree shows a process tree such as this systemd-+--agetty +--dbus-daemon +--login----bash---pstree +--systemd-qqsd I want to show a process tree with some specified attribute for each process (may be stat or pid... - options that you can specify with ps -o) Is there a way to achie...
How about top? Start top then hit V (capital V) to display process tree. Press f to select the fields to display.
How to show process tree with specified attributes
1,552,746,248,000
Ultimately I want to detect a new backup file being dropped into a directory and then move that new file to another location for other operations. This needs to work when there is nobody logged into the server and the script I use to start the operation will be triggered by a crontab entry. I tried using 'inotifywait'...
All you need is incron. Install incron package first if you have Ubuntu/Debian: sudo apt install incron or use the command for Red Hat/Fedora: sudo yum install incron Open file /etc/incron.allow in your favorite text editor - let it be vim: vim /etc/incron.allow and add new line with your user name (assume it's bob...
How can I use 'stat' to detect a new file and then move it to a different directory?
1,552,746,248,000
If I have a folder with the following file names: cluster_sizes_0.txt cluster_sizes_1.txt cluster_size_2.txt etc. Each file contains a single column of values. Is there a command within linux such that I could combine all files into cluster_all.txt? The first column in this new file would correspond to cluster_sizes...
The command paste merges columns together. So, for example, if we have these 3 files then paste will create the nice result: $ cat file_1.txt 1a 1b 1c $ cat file_2.txt 2a 2b 2c $ cat file_3.txt 3a 3b 3c $ paste -d, file_1.txt file_2.txt file_3.txt 1a,2a,3a 1b,2b,3b 1c,2c,3c So now the question is, really, how to ...
Combine files into one [duplicate]
1,552,746,248,000
I've created a user using sudo useradd -m peris but when I log in the terminal, I use the tab to autocomplete, but its not working, and it is working in the root user For instace I am in a folder where there are more folders like: menus-can-peris I type me and press Tab but menus-can-peris is not autocompleted $ ech...
The /bin/sh shell in Ubuntu is dash, which does not support tab completion. I suggest that you change the login shell for the peris user to a shell that does support tab completion of filenames, for example bash. You change the login shell using the chsh command whilst logged in as the user, or with chsh peris as root...
terminal autocomplete when there are several files/directory?
1,552,746,248,000
I’m trying to read some bytes out of /dev/urandom, keep only the ones I can type easily, and trim the result to 30 characters. I can’t figure out how to get the “only 30 characters” behavior when the data is coming from a pipe, though. I tried cat /dev/urandom | tr -cd 'A-Za-z0-9' | cut -c -30 and cut -c -30 /dev/ura...
cut will read the input until end-of-file, and cut a part out of each line. With the two first commands, you don't see anything, since tr removes any newlines, and so cut never sees a full line to process. In the last, the tr again removes newlines so you don't see how nicely cut kept the lines to a certain length. A...
Reading a certain number of bytes from standard input and then closing the pipe
1,552,746,248,000
I am using Cygwin on Windows 7 OS. I am trying to match an email of this format: x.y@enron.com This is my regex: grep [a-zA-Z0-9]+\.[a-zA-Z0-9]+@(E|e)nron\.com it returns -bash: syntax error near unexpected token `(' It works when used in regex101.com It should match emails like [email protected] and [email prote...
[, \, ( and ) all have special meanings to the shell and should be quoted if you intend to pass them verbatim in an argument to a command (here grep). Also note that ranges like [a-z] make little sense outside of the C locale. So here, you probably want: LC_ALL=C grep -xE '[[:alnum:]]+\.[[:alnum:]]+@(E|e)nron\.com' < ...
Cygwin unexpected token `(' with grep
1,552,746,248,000
I would like to execute a .blend file via terminal in a directory where only one .blend file is located. I would like to start this file without knowing the exact file name. If I knew the filename I would do it like this: blender --background example.blend --render-output //filename --render-frame 1
If it’s the only file in the directory (or even the only .blend file), all you have to do is run your command with a wildcard (a.k.a. glob, a.k.a. pathname expansion): blender --background *.blend --render-output //filename --render-frame 1
Open a single file in blender via terminal with an unknown filename
1,552,746,248,000
Different Linux distro have different file explorer. Is there any universal way(type the same command) to open the file explorer to a certain directory in shell(command line)? If it is possible, it is better to be suitable for any Unix-like OS. Thanks.
You're probably looking for something like xdg-open /path/to/directory, which should open up in the default file explorer. Of course, this only works on systems where xdg-like stuff is installed (so I would imagine mostly Linux systems).
How to open the default file explorer in shell?
1,552,746,248,000
I have a file that lists 5 lines of random words "See spot" "See pot run", etc each on a new line. I was able to create code that counted the number of times each word appears in the file and sorted properly. 4 Spot 3 run 2 see 1 sees 1 Run 1 Jane Code I used: cat "FILENAME" | tr ' ' '\n' | sort -n | u...
You could do with something like: tr ' ' '\n' <infile \ | sort -n \ | uniq -c \ | awk '{ seen[$1]++ } END{for (x in seen) print seen[x], x }' Or even: tr ' ' '\n' <infile | sort -n | uniq -c|cut -d' ' -f7 |sort |uniq -c Or better possible to do with awk alone: awk '{ seen[$0]++ } END{ for (x in seen) count[s...
How do you count the first column generated from uniq -c
1,552,746,248,000
Assume that the word child had to be replaced with son in a file consisting of sentences (not a list of words). It isn't a straight string replacement; for example, the following should not happen: children should not be changed to sonren but the following should happen: child. should be changed to son. child! shoul...
You can achieve this with sed command: sed -i 's/\<child\>/son/' /path/to/your/file -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied). The default operation mode is to break symbolic and hard links. This can be changed with --follow-symlinks and --copy. Considering your exam...
replace words in a file [duplicate]
1,552,746,248,000
I want to display the total time of the current MPD playlist in vimus, or if that's not possible, at least on the command-line (so I can display it in i3bar). How do I do that?
Found it, with the help of a friend. This solution ignores the time already elapsed in the current song, but heh, good enough. In the command-line: mpc playlist -f '%time%' | tr ':' ' ' | awk ' BEGIN {i = 0} {i += $1*60 + $2} END{ if (int(i/3600) > 0) print int(i/3600) "h " int((i%3600)...
mpd: how to display the total playlist duration
1,552,746,248,000
I'm looking for a way to bring down all other devices except the given one. I think it would be along the lines of greping the ifconfig output to then pull all the device names except the specified one and then use those names as input to an ifconfig $DEV down command.
The ifconfig is deprecated, use ip instead. You can use this simple script: #!/bin/bash if [ -z "$1" ] then echo "Device parameter missing!" exit 1 fi devices=`ip a | grep UP | cut -d " " -f2 | tr -d ":" | grep -v "lo" | grep -v "$1"` for dev in $devices do ifdown $dev done It is call...
How to bring down all internet devices except the specified one?
1,552,746,248,000
I am trying to obtain the pairwise combination of of string available for each stack of data, input file contains two columns: col1 is genenames, col2 is name of various stressors. gene1 FishKairomones gene1 Microcystin gene1 Calcium gene2 Cadmium gene2 Microcystis ...
AWK solution (will work even for unordered input lines): awk '{ a[$1]=($1 in a? a[$1]",":"")$2 } # grouping `stressors` by `gene` names END { for (k in a) { # for each `gene` len=split(a[k], b, ","); # split `stressors` string into array b for (i=1;i<len...
pairwise combination of string based on two columns
1,552,746,248,000
In bash, it is easy to pass newline as command line argument: foo 'this is a command line argument with newlines' However, if I try the same in tcsh, it complains about a missing '. How can I type the same in tcsh?
echo 'this has\ more than one line'
Newline in command line argument in tcsh
1,552,746,248,000
I'm new to linux about ten days, and my English is not good. I'm learning the I/O redirection part. I know when a command is successful, the screen do not display error message, and the command failed have one. For example when I input cat file1. Before the command issued. What is the state of stdin, stdout and stder...
Under normal circumstances stdin, stdout, and stderr always exist: ls -l /proc/self/fd But not all of them are used by every command. You can check where a command writes to: > strace -e trace=write cat nonexistfile write(2, "cat: ", 5cat: ) = 5 write(2, "nonexistfile", 12nonexistfile) =...
What is the state of the standard I/O stream while issuing a command?
1,552,746,248,000
In my Mac I already have a personal RSA key pair under ~/.ssh I would like to create a couple of RSA keys in my Mac but for another computer. So I don't want to run some ssh command and replace my existing keys somehow. Just create some key pairs for users A and B in a custom dir so that I can copy them where I need t...
Use the -f flag eg % ssh-keygen -f /tmp/foobar Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /tmp/foobar. Your public key has been saved in /tmp/foobar.pub.
Create ssh key pairs to copy elsewhere without messing up my personal ssh setup
1,552,746,248,000
I'm a newly minted CS major and I have been wondering what the benefits of using grep versus spotlight on mac. I ran a command to search for a specific file because I lost track of which directory it is in, which took a while, but when I did it in spotlight the result was instantaneous. I enjoy using the command line ...
Quick comparisons Iterative grep is usually to search file contents for matching patterns. Think searching file contents. grep will have to manually walk the file system from a given starting point. I am curious how you were using grep. find is the standard *nix command to search your file system for a file. Check out...
Grep versus spotlight on mac
1,552,746,248,000
I want to take a screenshot with import, and save it into a file whose name is current time. Here is what I've tried: sunqingyao:~$ date '+screenshot-%y%m%d-%H%M%S.png' screenshot-170716-173336.png # OK sunqingyao:~$ import screenshot-170716-173336.png sunqingyao:~$ ls -l screenshot-170716-173336.png -rw-rw-r-- 1 s...
You can always use command-substitution as the other answer suggests, or use xargs to use what pipe gives: $ date '+screenshot-%y%m%d-%H%M%S.png' | xargs -I {} import {} $ ls screenshot-* ...
Passing the output of a command to another in one line [duplicate]
1,552,746,248,000
This is my test .sh file. errorandoutput.sh #!/bin/bash echo myecho ls dflj If I run ./errorandoutput.sh >file 2>&1,then we can get such file But I hope the STDOUT information is after the STDERR.So I change the command into ./errorandoutput.sh >file 1>&2 But I get a empty file.How to make the the STDOUT informati...
That's not how order of redirection work. The order of redirection only determine the order of action the shell does with file description, not its content. In: ./errorandoutput.sh >file 2>&1 First, the shell redirect standard out to file, then redirect standard error to standard out, which is now pointed to file, so...
How to make the redirect file have a custom order
1,552,746,248,000
I'm using the below Network Switch: HPE ProCurve J8697A Switch 5406zl Software Revision K.14.34 I'm advised to execute the below command to know my network switch IP: tcpdump -i net0 ether proto 0x88cc -v -c 5 It is showing the following output but not executing completely and getting stuck there: dropped privs to n...
I guess you can, if you are connected to a host which is directly wired to the switch, do a : ping -b <yourBroadcastAddress> Chances are only the switch will answer as it will, most likely, depending on the brand of the switch and configuration, block broadcast ping from being forwarded.
Command to know the Network Switch IP
1,552,746,248,000
I have a file data like this: head data 19 54240283 . T C . . . 188,18:208:14:102:18:189:209:37.7222:37.4681:9:139:9:50:50.8889:40.3545:919.145:640.562:0 1 103020 . A C . . . 1,2:3:2:2:2:2:4:38:38:2:2:0:0:46.5:28:0.5:162:0 2 8797402 . G A . . . 0,3:3:3:0:3:0:3:3...
awk solution: awk -F'[[:space:]]+|:' '{ print $1,$2,$3,$4,$5,$6,$7,$8,$13,$14 }' data | column -t The output: 19 54240283 . T C . . . 18 189 1 103020 . A C . . . 2 2 2 8797402 . G A . . . 3 0 -F'[[:space:]]+|:' - whitespace(s) and : are considered as field separator
How to extract out information separated by a character from a column?
1,552,746,248,000
I have the file ole.txt: A B C 1 2 3 a b c 11 22 33 with option A: cat ole.txt | sed -n -e 1p -e 3p we get: A B C a b c with option B: sox=$(cat ole.txt | sed -n -e 1p -e 3p) echo $sox we get: A B C a b c How can I change the code in option B to get the result in option A (the result as 2 ro...
Quotes is the answer. echo "$sox" should do the trick. If you don't want a newline at the end, you can use printf "$sox" Taking a look at the Linux Documentation Project's page on quoting variables might help you understand better what weak quotes, i.e. ", entail.
Get variables in two separate lines
1,552,746,248,000
I was trying to move a file with mv to see it works and now I cannot find it. The command I entered was: sudo mv ~/Documents/Books/UTMAnalysis.pdf /Desktop I am using OS X. Similar questions mentioned it might be in the root directory or somewhere as a hidden file. In the root directory there is a Desktop, but is ...
I suspect one of the following: renamed If /Desktop did not exist when you ran that command it would have renamed the file "UTMAnalysis.pdf" to be "Dektop". You could confirm if it was a directory or a file with this command: ls -ld /Desktop If it's a directory the first character will be a "d" whereas if it's a file ...
Attempted to move a file with mv command and now it is lost?
1,552,746,248,000
I'd like to find files with the wav extension having the same filename, only different in extension (which is mp3) in the same directory. I tried the following structured command so far: $ diff -s $(for i in *.wav; do echo "${i%wav}"; done) $(for i in *.mp3; do echo "${i%mp3}"; done) diff: extra operand `abc(xyz' diff...
If you want to diff the output of some commands, use process substitution <(...) instead of command substitution $(...). Otherwise that seems it should work. diff $(foo) puts the output of foo on the command line of diff, while diff wants the name of a file to read. diff <(foo) arranges for the output of foo to be ava...
Compare two file listings to find identical files but ignore extensions
1,552,746,248,000
I have about 700 folders. Each folder contains pairwise combinations of files. I would like to retain only one file per pairwise combination. Any of the pairwise files can be retained as both contain the same content. The files in the folder are not necessarily named in alphabetical order. Example: Folder1: ...
You could do something like ls *.txt | awk -F '[.-]' '{ if (f[$2,$1]) { print $0; } else { f[$1,$2] = 1} }' | xargs rm This works as follows: feed the names of the relevant files to awk. For each file, check if a file with reversed name has already been entered in the array f. If so, o...
removing pairwise duplicate files
1,489,055,014,000
I'm trying to set remote backup for my website. in /etc/rsnapshot.conf, I've set the following things but its still not working. snapshot_root /abc_backups/ backup [email protected]:/var/www/abc.com/html/ Can anyone help me out on how to set this? My website server is on 1.2.3.4 and the source is /var/www/ab...
Are you sure you have a abc_backups directory at the root of your filesystem? I really doubt it (and even if you did, this is not a good practice). Also backup takes 2 arguments, not one as in your example. First the source (what you backup) and then the destination. Based on your description, change your backup line ...
rsnapshot settings confusion
1,489,055,014,000
I am looking for a tool that runs via command line. sort of like xprop xdotool it simply needs to allow me to draw a rectangle on the screen. and tell me the measurements of it. I have tested out: "import" module by "imagemagick".. but perhaps there is something much lighter out there ? ( or perhaps even something ...
Some workaround. You'll need gnome-screenshot and imagemagick packages as well as a few standard commands. We'll simply define a random file name (in the temporary directory /tmp), take a screenshot and write it to said name, then analyse the image's dimensions (picking the pixel size only) and finally remove the imag...
A Tool to measure onscreen drawn rectangle? [duplicate]
1,489,055,014,000
file contains just 1 line: aaa when I run "cat file" it mixes to username user /dir : cat file aaauser /dir : What could be the problem ? Extra Info: perhaps this is not properly set in bashrc ? ? PS1='\u \W : ' UPDATE: shouldnt there be a solution other than including a newline to the file ? Why would there be no ...
Your file does not have a newline at the end. As a result the shell prompt is just put right on the end. You could fix that by adding it. printf '\n' >> file You can recreate this issue by creating a file without a newline at the end. (The -n flag tells echo to not add a newline at the end.) [zbrady@server ~]$ print...
cat file : prints prior to "user :/" prompt
1,489,055,014,000
I often use reboot -n and shutdown -t now commands to restart and shutdown my system. Is there something similar to log out of the current user account? That is logout of my user session for the whole session. I'm using Ubuntu server with i3 so maybe I'm looking for an Ubuntu specific answer(?)
logout is used by users to end their own session
command to log the current user out of the system?
1,489,055,014,000
Assume, you have a Linux machine and there are three users - user1, user2 and user3, who can log in to the machine. You created a rule $ auditctl -w /etc/file.txt -p rwxa If you would like to see daily, who and in what time accessed the file.txt how would you do it to minimize information overload, because you use a f...
There are user-space tools for filtering and reporting audit events. See https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sec-Creating_Audit_Reports.html for some examples. For your case you could try something like: ausearch --start today --success no --file /etc/file.txt |...
Viewing relevant information about file accesses from the audit log
1,489,055,014,000
I created a zip archive named tmp.zip. It has a size $ du -h tmp.zip 1.7G tmp.zip I copied it to flash drive $ du -h /media/tb/tmp.zip 1.5G /media/tb/tmp.zip What's wrong here? How can I check what is missing in the archive on the flash drive if something is missing?
The two filesystems most probably use different blocksize, this can change the graininess with which filesizes can be assigned.
Zip file has different size after copied to flash drive
1,489,055,014,000
I have a CSV formatted multi lines file with 5 columns (fields). I need to unify and corrected the corrupted first column which has lots of different formats of the code I need to unify. The complete final format of my code for the first column should be 00AB[0-9][0-9][0-9][0-9][0-9] which [0-9] could be any number su...
Maybe: awk 'sub("^0?0?A?B?","",$1) && $1=sprintf("00AB%05d",$1)' Delete any leading 00AB fragments from field 1, then convert it to 00AB followed by the rest of the number padded with zeros up to length 5. The expression is always true so the implicit { print } action fires. The sub is always true because the regular...
How to use awk to correct and unify a corrupted file with multiple columns and lines?
1,489,055,014,000
When using some Tor browsers, for instance in iOS, I have a nice list with speeds and countries from which I can choose the relay points that can be used/from which I do get out. Can I get such a list from the Linux command line when running the tor daemon?
As the post related to man tor describes Does the Tor Browser Bundle cache relay information?, there is such a file with cache information in the system. DataDirectory/cached-consensus and/or cached-microdesc-consensus The most recent consensus network status document we’ve downloaded. So in Debian, the file w...
How to get tor relay points through the Linux command line?
1,489,055,014,000
Consider this directory (and file) structure: mkdir testone mkdir testtwo mkdir testone/.svn mkdir testtwo/.git touch testone/fileA touch testone/fileB touch testone/fileC touch testone/.svn/fileA1 touch testone/.svn/fileB1 touch testone/.svn/fileC1 touch testtwo/fileD touch testtwo/fileE touch testtwo/fileF touch tes...
Your find commands not saying what to do if the given path is not matched. If you want to exclude everything that starts with a dot, and print the rest try: find test* -path '*/.*' -prune -o -print so it'll prune anything that matches that path, and print anything that doesn't. Example output: testone testone/fileC ...
Find files in globbed directories excluding some subpaths
1,489,055,014,000
I'm running a program called gatk-picard.sh and it's printing out the running history/log (INFO rows below). Since the program will take about 20 hours to finisn and I wanted to put it on running when I am leaving my office but would check the running history in my home. How to save these history lines automatically a...
It's probably writing to stderr (file descriptor 2) instead of stdout (file descriptor 1, the default). > filename (which can also be written as 1> filename) redirects stdout to a file. You can either redirect stderr to stdout first, like this: gatk-picard.sh 2>&1 > log or you can write stderr to its own file, like t...
How to save a program's running history to a file?
1,489,055,014,000
For the encrypted base64 encoded SHAX strings, what command can decrypt it back to original string, thanks
From the linked post, your original string was generated by a method such as echo -n foo | openssl dgst -binary -sha1 | openssl base64 What this generates is a digest, with SHA1 being the method of calculating the digest. In this situation there is insufficient data to reconstruct the original string. This digest is...
How can I decrypt back a base64 encoded shaX binary string?
1,489,055,014,000
How to force Fedora command-line to give me proposals for installation of package when a missing command is typed? Now when I type git the command-line tells me : -bash: git: command not found Before it gave me proposal (something like this): Command not found. Install package 'git' to provide command 'git'? [N/y] ...
You have to install PackageKit-command-not-found package: dnf install PackageKit-command-not-found It is fine to check its config /etc/PackageKit/CommandNotFound.conf for some details (it's well documented), but default config should be enough.
Fedora command-line installation proposals [duplicate]
1,489,055,014,000
As dhcpd negotiates it prints its output on the login prompt, which clutters (messes up, wrangles, uglifies, writes over, obscures [synonyms for googlers]) the console login prompt. How to inhibit dhcpd from outputting over the console login prompt? Running Void Linux with runit, /etc/sv/dhcpd/run looks like this: #!/...
Duncaen on #voidlinux at freenode gave me this link. Apparently this chaotic outputting comes from dmesg, not dhcpcd. Solution is to add dmesg -n 1 to /etc/rc.local.
How to inhibit dhcpd from outputting over the console login prompt?
1,489,055,014,000
This command will open firefox in the private browser mode correctly firefox -private & However this command is only opening firefox in regular browser mode. firefox -private& What is the difference between these two commands?
The space is actually irrelevant. The shell parses the command in exactly the same way. The difference is whether Firefox is already running or not. It appears that the -private option only works when starting Firefox. If Firefox is already running, firefox -private opens a non-private window in the existing Firefox i...
firefox -private sometimes opens a non-private window
1,489,055,014,000
I run two separate instances of vifm on my machine: $ vifm --server-list documents photos In one I'm organising documents and in the other photos. Sometimes I'm inside a third shell and would like to give commands to one of the vifm instances. Had I only one instance I would do: $ vifm --remote -c 'normal p' But t...
You need to specify additional argument you already know about (as you named your instances by using it): $ vifm --help | grep -A1 server-name vifm --server-name <name> name of target or this instance. Note this part: name of target ... instance. In your case end command will look like the following: $ vifm -...
How do I select which remote vifm instance will run a command?
1,489,055,014,000
I need to upgrade some specifics packages from sid on debian jessie stable with their dependencies. By adding the following repo : deb http://ftp.fr.debian.org/debian/ sid main deb-src http://ftp.fr.debian.org/debian/ sid main deb http://ftp.fr.debian.org/debian/ sid main contrib non-free deb-src http://ftp.fr.debia...
"Going hybrid" with Debian versions is not always worthwhile, (or safe, or reliable, etc.), but sometimes it works. The hybrid version's best case is when a package from testing or unstable makes only trivial changes, (in perpetuity even), and everything works smoothly thereafter. Possibly it's already been packaged ...
How to upgrade/downgrade a specific package from "sid" on debian jessie "stable"? [duplicate]
1,489,055,014,000
I am trying to lookup the WhoIs entry for the following domain: anorien.csc.warwick.ac.uk However, while typing the URL directly into the browser displays a web-page, when I type: whois anorien.csc.warwick.ac.uk into the Linux command-line I get the following error: No such domain anorien.csc.warwick.ac.uk How is th...
The only valid WHOIS registrations are for licensed domains only. However, if you own the primary domain, you could setup your own WHOIS server that could be queried for subdomains that you register under you. Code: whois -h whois.yourdomain.com subdomain.yourdomain.com It is not difficult to setup a whois server if y...
Website is active but domain name not showing on WhoIs lookup from Linux command-line
1,489,055,014,000
I am trying to make a program that will copy file1 into file2 the following way: cp -i -p file1 file2 Now I call my executable copy and so by calling copy file1 file2 It will do the same thing like the first command (-i and -p). I was able to do this using execl char const *copy[] = {"/bin/cp","cp","-p","-i",0}; ...
Change your copy array, and the function call. The following is a minimal example: #include <unistd.h> int main(int arcg, char *argv[]) { char *const args[] = {"cp","-p","-i", argv[1], argv[2], 0}; execv("/bin/cp", args); }
How can I succesfully call the execv function? [closed]
1,489,055,014,000
If I use grep -q in combination with -v to return 0 if there are no matches or 1 if there is a match, it works as long as input is a single line: $ echo 'abc' | grep -q -v a; echo $? 1 $ echo 'abc' | grep -q -v x; echo $? 0 But if the input is multi-line, grep will always return 0: $ echo -e 'a\nb\nc' | grep -q -v a;...
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 tho...
Why "grep -q -v" only works with single line input?
1,489,055,014,000
I am trying to use an argument of the script to find other files. The problem is that when i give the script the argument x.* in the command line, it is transformed into x.sh. Any ideas how i can get the x.* inside my script? The script in comand line : ./script.sh x.*. If i try to print $1 it outputs x.sh.
You can't do it from the inside of your script. * has to be escaped, otherwise it will try to fit filenames (in your case x., then anything, as * is a glob operator that matches any string in filename). You can do it in, basically, three ways - enclose your string with single or double quotes: ./script.sh "x.*" ./scri...
How to prevent bash from transforming arguments?
1,489,055,014,000
I am running TCSH and I would like to update my prompt every time I run a command. I think can currently do that via backticks. set tmpstr = `git status --untracked-files=no --porcelain` set prompt="%{\e[35;1m%} $tmpstr %{\e[32;1m%}%n%{\e[37m%}@%{\e[33m%}%m%{\e[37m%}:%{\e[36m%}%~%{\e[37m%}"\$"%{\e[0m%} " But I re...
I ended up using precmd I put alias precmd 'source ~/.tcsh/precmd.tcsh' into my .cshrc file and moved my prompt set into that file. Source of the .tcsh set tmpstr = `(git status --untracked-files=no --porcelain >! ~/out ) >&! ~/out1` #echo $tmpstr #for debugging if !( -s ~/out ) then if !( -s ~/out1 ) t...
Updating a git variable in the Shell prompt on every command
1,489,055,014,000
I often run a series of poor-man daemons when I am sshing into my headless server. One to monitor the beer in my kegs and one to monitor the server itself from a web-browser. I do this by running both in screen: screen -d -m psdash screen -d -m kegbot runserver xxx.xx.x.xxx:8008 Both commands outside of screen tend ...
I'd suggest writing the PID (in bash that's in $! after starting a process) into a file, of the two processes you're starting (psdash and kegbot). You can then use ps --pid $(cat your.pid) | tr -s ' ' | sed 1d | cur -d' ' -f4 to see if the process is actually running. Just as a side note, you should always check whet...
How to run commands on user login -- that are NOT already running
1,489,055,014,000
I'm trying to run my Java code remotely using SSH. I need to do this with qsub, so I've created a short bash script that compiles my Java files and then runs the main one. Here's the thing: My code (when run without qsub) prompts the user for a file name and a user name. When run with qsub, it doesn't do this but th...
qsub submits your java program to a batch queuing system, and eventually it runs on one of the compute nodes in the cluster - how do you expect to be able to interactively input data in that situation? there is no tty or screen or keyboard. You need to modify your program to take command line arguments and give the f...
Running interactive java code with qsub
1,489,055,014,000
Let's say I have a directory ~/mydir that has a whole bunch of text files in it. I want to search for searchterm in this directory and then view the file that has the most matches. How can I do this using only one command?
Putting the following line in a script will do it: grep -c "$1" ~/mydir/* | grep -v ':0' | sort -t: -k2 -r -n | head -1 | sed 's/:.*//' | xargs less Then just call ./myscript searchterm If you want to search recursively, change -c to -cr in the first grep command. The parts of this pipeline, in order: grep -c "$1" ~/...
How can I open the file with the most matches for a given regex?
1,489,055,014,000
I'm running Arch Linux in a virtual machine and it's getting REALLY annoying that since some thing require that I cannot be root, I need to sudo most of my commands. It would be nice if I could do something to detect a command needing root, and automatically run/re-run it with sudo giving it root powers. Can someone ...
When you need to perform maintainence, upgrades, configuration and other tasks that require root, run sudo -i to get a root login shell (i.e. with all env vars, aliases, functions etc as if root had actually logged in). Run whatever commands you need, create/edit/delete/move files, all as root - without needing to pre...
Automatically rerun something with sudo if root needed [duplicate]
1,489,055,014,000
I have strings similar to the following: *unknown*\*unknown* (8) hello\morning (3) I'm trying to match just morning or *unknown\*. So far I have tried: [^\\]+$ But that matches from backslash to end of line which isn't what I want.
With grep: grep -oP '(?<=\\)[^\\ ]+' file -o prints only the matching pattern. The (?<=...) is a positive lookahead which matches the backslash \\, but it is not part of the matching pattern. The second pattern [^\\ ]+ follows the backslash and contains all characters, but no backslashes and no spaces. The output: *...
Match everything after backslash and before space
1,489,055,014,000
I would like to download several images (from a server with a self-signed certificate) and view them all with feh. Is this possible with a single command? Something like curl -sk -b path_to_session_token url1 url2 | feh - - except this only feeds feh one of the files. Preferably without saving to a file and deleting i...
feh will not be able to distinguish between several images sent on its standard input, unless some kind of "protocol" is implemented. If you don't want to use temporary files, you could maybe use a loop: for url in 'url1' 'url2'; do curl -skb token "$url" | feh - done This will download and display each image one...
Pipe multiple files from curl to other program
1,489,055,014,000
I want to run a command which searches for specific files, then removes them then show how many already is deleted. So far I was using: find -type f -name "*.cache" -exec rm {} \; but when I have over 400k files, I'd like to know how much already was deleted like: 1 - file1234.cache 2 - file121342.cache 3 - file15467...
Will satisfy you find -type f -name "*.cache" -exec rm -v {} + | nl
How to Find, remove and show counter via SSH?
1,489,055,014,000
Here is the situation. I often have to read chunks of information from large plain text files. I am planning to use Readability extension for formating the content to make it readable on screen.
You can use xclip to paste the contents to a temporary file and then open that file with firefox. For example: temp=$(mktemp); xclip -o > $temp; firefox "$temp" mktemp generates a temporary file in /tmp, xclip -o pastes the contents of the clipboard to that file, and at least firefox open that file as if it were a w...
Can I pipe clipboard content to browser for viewing?
1,437,404,310,000
I just installed AWS CLI on a few servers with Ubuntu 14 on. The last server I installed it on, cannot access the AWS CLI from the terminal and run commands. This does not work: aws --version You need to do this: /home/user/.local/lib/aws/bin/aws --version How can I make aws --version work in the same manner it does...
PATH Variables needed to be added. cd ~ vi .profile Append: :/home/user/.local/lib/aws/bin/ Behind: PATH=":$HOME/bin # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH:/home/user/.local/lib/aws/bin/" fi aws --version
Application [AWS CLI] Command shortcuts are not working globally
1,437,404,310,000
Background I have a text file, named blood_conc.txt as shown: 0, 0, 0, 0, 0, 0, 0, 1.32006590271e-05, 1.990014992001e-05, 1.504668143682e-05, 2.176900659261e-06, 7.673488970859e-06, 2.169217049562e-05, 4.343183585883e-05, 0, 0, 0, 0, 0, 0, 0, 2.143804950099e-05, 0, 0, 1.849919603625e-06, 0, 0, 0, 0, 0, 0, 0,...
You can try this with awk: awk -F"," 'NR == 3, NR == 8 { for (i = 1; i <= NF; i++) { if ($i == 0) { cnt++; } if ($i >= 2.452555e-05 && $i <= 0.0032784) { cnt1++; } } } END { print cnt, cnt1; }' file
Count frequency of specific numbers in a text file of scientific notations
1,437,404,310,000
I want to write the process id and command of all processes with some name and from some user (for example root and init). What should I do? ps -f -u root -C init or ps -f -U root -C init writes more then just init the process.
If you only want the process ids, why not use pgrep: pgrep -u root init Or: pgrep -U root init Which switch you use (-u/-U) depends on what you want. The difference is, -u matches the effective uid and -U the real uid: The effective uid describes the user whose file access permissions are used by the process. The r...
process id and command
1,437,404,310,000
This seems like a basic question and there are variations of it. I have a ONE-COLUMN html file (let us call it status.html). I would like to send this file which has a few images as the BODY of an email. I would like to do this using the Linux command line, but I am unsure of how to proceed. I do not know how the imag...
"-a" Attach a file to your message using MIME. When attaching single or multiple files, separating filenames and recipient addresses with "--" is mandatory, e.g. mutt -a image.jpg -- addr1 or mutt -a img.jpg *.png -- addr1 addr2. The -a option must be placed at the end of command line options. –
Sending a HTML file (with images) as email body using command line
1,437,404,310,000
How do I run diagnostics against Asterisk? Asterisk is running on tleilax; and doge is on the same network (My network topology isn't optimal). Specifically, I want to do something like: sipp [email protected] except I'm not sure what flags to send. How do I send "hello world" to [email protected]? (Note that this...
You should use domain from your realm,not ekiga You can troubelshoot by using asterisk -r sip set debug on
SIPp "hello world" message to Asterisk
1,437,404,310,000
I have a folder working and its structure is something like this - working/ 100/ 1/ 2/ 3/ 200/ 1/ 2/ 3/ 300/ 1/ 2/ 3/ And each of these 1 2 3 folders have around 1000 files. I want to zip the files under the 1 2 3 folders separately. The zip should not conta...
A simple loop will do the trick. cd working for dir in */*/; do [ -e "$dir/files.zip" ] || # skip directories where the zip already exists ( cd -- "$dir" && zip -r files.zip .) done Note that zip is smart enough to skip the zip file that is being built when recursing in that directory. Some other archiving prog...
How to zip only files under multiple subdirectories?
1,437,404,310,000
I'm looking at the output of w: ehryk@ArchHP ~> sudo w 14:12:37 up 4:08, 4 users, load average: 2.18, 1.93, 1.55 USER TTY ...
You can use watch command to constantly running w (every some time defined in -n parameter). For example: watch -n 1 w will run w every second. Output of w will be kept on top of the terminal window.
How do I keep running a command in the same area of the console window? ("w")
1,437,404,310,000
I can extract list of patterns using following command, fgrep -A 1 -f patternlist.txt filename.fasta but, is there a way I can extract without creating another file (patternlist.txt in this case) from other command's output? Such as: cut -d " " Cell_cycle.txt -f 1 | grep ...???... filename.fasta EDIT: The Cel...
Use process substitution <(): fgrep -A 1 -f <(cut -d " " -f 1 Cell_cycle.txt) filename.fasta
Extracting list of patterns which are output of another command
1,437,404,310,000
I am trying with: $ sudo iwconfig wlan0 essid mynetwork key 4bare2011 $ sudo iwconfig wlan0 essid mynetwork key 4bare2011 mode Managed and similar combinations. I'm using Ubuntu 14.04. The key is right and works for other clients. But it doesn't get accepted. s:4bare2011 is also getting an error message. ddddddddd...
An alternative to using iwconfig and wpasupplicant "by hand" is to edit /etc/network/interfaces and add a stanza like iface wlan0 inet static address 192.168.x.x netmask 255.255.255.0 gateway 192.168.x.1 dns-nameservers 192.168.x.1 wpa-ssid mynetwork wpa-psk 4bare2011 or iface wlan0 inet dhc...
Trying to connect through cl
1,437,404,310,000
Is there any way to check/find files and directories that only I created and check their permission?
To list all the files out in this manner you can use the tool find, along with the switches -user <username> and either -ls to get a standard type of ls output, or you can control it more specifically, using the -printf switch, telling it which columns, and in what order you want them. $ find /path/to -user <username>...
Checking permission for files
1,437,404,310,000
Suppose I click on a file in Nautilus. How can I copy the full address to the clipboard, and then easily paste it into a shell command that I'm typing in a terminal?
Press Ctrl+C to copy. When you paste into a terminal, what you'll get is the file name (with its full path). You get the raw file name, which won't be directly usable in a shell command if it contains spaces or other special characters. To use the file name in a command, don't use a paste command from the terminal, le...
Copy a file in Nautilus and use it in a shell command line
1,437,404,310,000
To paste many files, whose names are incremental numbers: paste {1..8}| column -s $'\t' -t What if your files wasn't named by number, but only words? It can be up to ten files, what should I do? In addition, you have a list of files that contains all the files you want. So far, my approach is: mkdir paste j=0; whil...
With bash 4 mapfile -t <list paste "${MAPFILE[@]}" | column -s $'\t' -t for the paste {list}/PQR/A/sum version of the question mapfile -t <list paste "${MAPFILE[@]/%//PQR/A/sum}" | column -s $'\t' -t
How to use paste command for many files whose names are not numbers? (paste columns from each file to one file)
1,437,404,310,000
I have a file full of long SQL queries, one per line. I need to create a list of unique queries, but most of the queries include parameter values that make using an exact matching tool like uniq impossible. Is there a way to find unique lines "fuzzily", like agrep?
If the queries are predictable enough, maybe you could simply sed out the parameter values--e.g. if many queries contain equality comparison with numbers, sed 's/=[[:digit:]]+//g' would remove all the actual numbers, leaving only the column names. Otherwise, the only really general solutions I can think of are pattern...
A combination of uniq and agrep?
1,437,404,310,000
I have looked all around but couldn't find the answer to a very simply question: I would like to log into machine C from machine A, passing through machine B. However, B is slow, so I would also like my connection to C to be compressed/decompressed at C, tunneled through B, and decompressed/compressed at A. What ssh...
Assuming you have: A with ip address ip_A B with ip address ip_B C with ip address ip_C From a first terminal connect to the B and set a tunnel to C on ssh (port 10022 is used for the tunnel but it can be anything else): ssh ip_B -L10022:ip_C:22 Then from another terminal, you will be able to connect "directly" to ...
log into a machine through another, with (de)compression at the ends only [duplicate]
1,437,404,310,000
Forgotten how I did this last time. Tried the following 2 methods that I thought had worked for me in the past: method #1 $ wget \ http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.rpm method #2 $ wget --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "yourvers...
This worked for me: $ wget --no-check-certificate \ --no-cookies \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \ "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.rpm" If you truly want to dump this file to /op...
can't wget rpm oracle on centos linux
1,437,404,310,000
Suppose I am in an area with a lot of Wireless AP's for a particular SSID. If I run the command sudo iw dev wlan0 connect <ESSID> How does iw decide which AP to connect to? It does not seem to be based on signal strength, since the one it connects to is not the one with the best signal strength.
First Responder, but this happens at the hardware/firmware level and is not strictly a function of iw. There's no standard that I am aware of, just common practice. Most things network default to first responder, So most firmware follows suit. Typical firmware can not be tuned, but I have seen a very few that can be. ...
What is the algorithm that the `iw` command uses for choosing an Access Point for a given Wifi network?
1,437,404,310,000
"Hmm, I need to edit file-i-must-edit-2, but I cannot remember where it is." locate file-i-must-edit /home/user/file-i-must-edit-1 /home/user/file-i-must-edit-2 /home/user/file-i-must-edit-3 "Great! I wish there was a way to avoid typing /home/user/file-i-must-edit-2 again..." Is there a way to avoid typing nano /hom...
If you get only one line of output, it's easy: locate file-i-must-edit nano $(!!) There is a technique you can use when there are more lines, but it involves running the original command in a different way (which you may not want to do all the time): $ touch a b c $ OUT=( $(find .) ) $ echo ${OUT[2]} ./b One thing y...
Getting specific line from terminal output
1,437,404,310,000
Is it possible to retrieve info regarding to locked unix accouts? I am interested in seeing information about what date and time the lockout happend and from what hostname (pc name). I would like to see something similar to the who command.
I don't believe this information is kept anywhere. They only place you could get some of this type of information would be from the sudo command logs, assuming you're using sudo and that your sudo setup gives out permissions such that you're logging on individual commands such as passwd. I've used this command before ...
How to retrieve information about locked accounts
1,437,404,310,000
Lets say the python repl takes a long time to start up, is there a way to start it up in the background so I can create an alias and feed it commands like python-current "command to run".
There is nothing in the python distribution of doing this kind of opening, 'batteries included' not withstanding. That programs like editors can handle that kind of thing, is because it is quite clear what to do when you open another file: you just open a window/tab on the new file, handled by the same executable. Imp...
Start Repl/CLI in Background and Feed Commands
1,437,404,310,000
I remember hearing about something similar. My constraints are: It may not be installed on the machine It may not be booted via USB or LiveCD What I need, in decreasing order of priority: 0. free 1. gcc, binutils, bash 2. low network traffic e.g. =< 1kbps 3. sufficient resources to cross-compile gcc 4. ability ...
I don't really understand why you have such unusual constraints. No installation, no live CD and low network traffic excludes the obvious solutions like booting a distro from USB, setting up a VM or using a remote system via SSH. How do you actually plan to run such a system? If you really only have a browser check ou...
Is there a linux distro, that is not installed, but runs from the browser?
1,437,404,310,000
The application I am referring to is Turpial and it is a Twitter client. The problem is to open the window I need to send twits, I have to right click on a systray icon and select an option. In the manual (man turpial), I can't find a command to open the 'send twit' window, just the timeline window. After I open the w...
Unfortunately, I do not believe this is going to be possible with Turpial, or indeed any client which has not been designed to work with KDE's Global Shortcuts interface. However, if you are not bound to Turpial then a client that seems to offer exactly what you are looking for is Choqok. It has a similar lightweight ...
How to configure a shortcut to open a window accessed by right click on the systray icon?
1,437,404,310,000
On MacOS X I can run open /some/path/index.html and this would open the page index.html with the default software that handles .html files. Is there something similar on Ubuntu Linux? I have used gnome-open in the past, but if there is no gnome installed, this command fails, of course. gnome-open /some/path/index.htm...
A desktop-environment-agnostic open utility is xdg-open, which could fill your need. It's probably packaged with some other utilities of xdg-utils. It's discussed here quite often, see for example this question for details on configuring it. (Other desktop environments come with *-open utilities, too, e.g. there is X...
How to open a local URL (webpage) on the command line