date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,654,992,595,000 |
I want to find screenshot files, having a specific pixel height of 2220 and width of 1080, and want to move them into another folder. That's nothing I can do manually, as the source is 100+k images or so.
I've found the following command, but not able to bring it to work:
find /Users/myuser/Desktop/daten/JPG -name "*.... |
Just to close this question: I have managed to move and finally remove all screenshots with the following command:
find ./JPG* -name "*.jpg" -exec bash -c "sudo exiftool -csv -s -ImageSize {} | grep > /dev/null 'x2220'" \; -exec mv {} ./screenshots/ \;
| Find images with specific pixel height/width and move them in another directory |
1,654,992,595,000 |
Is it possible to get either the free or used ports between a specific range? If yes, whats is the command?
Thank you in advance!
|
Read man lsof.
sudo lsof -iTCP:20-26
Will show in-use ports.
| Get free/used ports in a specific range |
1,654,992,595,000 |
I have a series of 297 directories named as "dir000', 'dir001' and so on, each of which contains a text file called "config", which is a csv file with 3 columns and 256 rows. I have generated 25 random numbers in the range 1 to 256, and from all these files in each directory, I am required to remove those exact 25 row... |
The following uses perl's -i option for in-place editing of the input files.
#!/usr/bin/perl -i
use strict;
# Parse array of random numbers from the first argument.
my $arg1 = shift;
# remove [, ], and any whitespace.
$arg1 =~ s/\[|\]|\s+//g;
# split $arg1 on commas, build an associative array
# (aka "hash") calle... | Deleting lines of a series of ASCII (.csv) files having a certain row number |
1,654,992,595,000 |
I work on Geany because it is lightweight and simple. But one future I really miss from using sophisticated and heavy code editors is prettifying the code with a keystroke. But Geany allows external scripts to run on the text in the editor through "custom commands".
So I am on the look out for CLI program that can pre... |
First install prettier "globally" using either npm or your Package manager.
Using npm:
npm install -g prettier
To "prettify" CSS using "custom commands" with Geany:
Config - One time only!
Edit -> Format -> Send selection to -> Set custom commands
Click Add
Enter prettier --stdin-filepath temp.css in Command field.
... | Is there a command line application that can prettify text containing HTML + CSS + JS? |
1,654,992,595,000 |
I tried opening files with vim using vim $(cat filelist) as suggested from this earlier question.
Suppose I have the following file:
~/Workspace/bar/foo.cpp
Executing vim $(cat filelist) from ~/Workspace correctly opens foo.cpp when filelist contains bar/foo.cpp. However, the command does not open the file when filel... |
This is due to the order in which the different types of expansions are performed in a shell. The bash manpage says:
Expansion is performed on the command line after it has been split into words. There are seven kinds of expansion
performed: brace expansion, tilde expansion, parameter and variable expansion, comman... | Opening files in vim with a filelist not working |
1,654,992,595,000 |
Basically, I'd like to use a launcher to open a new tab with a program running in it when I already have a terminal open (obviously). To do this I use
xfce4-terminal --tab --drop-down -x
You'll notice I'm also using the
--drop-down
Which is essential to my ideal set up but am unsure if it matters to my question, but... |
A simple script like this can be used to prevent the empty tab:
#!/bin/bash
c=$(ps -e | grep -c xfce4-terminal)
if [ $c -gt 0 ]
then
xfce4-terminal --tab --drop-down -x $1
else
xfce4-terminal --drop-down -x $1
fi
Assuming the script is named xfce4termtab, the launcher command would be either... | Is there a way to prevent an empty tab from showing up when using the --tab switch in a launcher for xfce4-terminal? |
1,654,992,595,000 |
I know how to view the current processes on my Ubuntu machine. For example, I can leave a ping running:
ping localhost
Then do:
$ ps -ef | grep ping
Which shows:
user1 2875 1231 0 Feb08 ? 00:00:03 /usr/libexec/gsd-housekeeping
user2 96834 43257 0 14:21 pts/4 00:00:00 ping localhost
root ... |
The ping runs once: it has its own internal timer to repeat the task, but the same process stays there until the count expires, or you kill it, depending on options.
Host is an external command, not a shell built-in, so this is nothing to do with sub-processes. But it runs to completion 50,000 times. The probability o... | How to view process info for "host" and similar commands |
1,654,992,595,000 |
I have some .tta files I downloaded from internet. I can play them on VLC locally, but they cannot be played from certain media player app, for example, an android app. So here I need to convert "tta" files to "mp3" or "wav" files. Since they're high resolution sound, I'd like to know how to convert them to wav (or fl... |
for i in *.tta; do
ffmpeg -i "$i" "${i%.tta}.wav"
done
| Convert TTA file to MP3 or WAV file? |
1,654,992,595,000 |
The documentation mentions no command-line arguments for launching the setup program. The Windows version appears to have a dedicated executable.
|
It’s a separate executable on Linux too, chocolate-doom-setup (which is a link to chocolate-setup).
Each game variant has its own setup: chocolate-heretic-setup, chocolate-hexen-setup, chocolate-strife-setup.
| How to access the setup tool in chocolate-doom? |
1,654,992,595,000 |
The man page for txt2html says:
--make_links
Should we try to build links? If this is false, then the links dictionaries are not consulted and only structural text-to-HTML conversion is
done. (default: true)
I want to set this to false. How do I do this? I could not find this informatio... |
The txt2html manual also says
Boolean options can be negated by preceding them with no [...]
The manual then refers to the Perl package Getopt::Long. In its manual, one may read the following about boolean options:
The option does not take an argument and may be negated by prefixing it with
no or no-. [...]
This ... | How to specify boolean value in argument to external command? |
1,654,992,595,000 |
I've create a zip archive using the following command:
zip -e myfolder.zip myfolder/
Which prompts for a password and compresses the folder without errors. Now I'm trying to unzip the archive using this other command:
unzip myfolder.zip
which should supposedly ask for the password I set before, but doesn't - it just ... |
Since you did not use the -r option when creating the archive, your archive contains only the directory, and not the files inside it.
Apparently the encryption of a Zip file does not extend to protecting the directory structure, just the contents of the files. As a result, if a zip file contains only directories and n... | password protected .zip extracts to empty folder (without prompting for password) |
1,654,992,595,000 |
I'm trying to measure the CPU% consumed by my app on a multi-core machine, meaning htop CPU% reports can go over 100%. I'm trying to get a simple read on CPU usage difference when I run my app in one configuration vs. another, but the change is likely less than 1% CPU and I'm seeing the following "107." for my proces... |
I'm pretty sure that is going to be wasted precision*, in the sense that once you get to four significant digits the sampling would have to be accurate to more than 1 part in 1,000 and for five digits it would have to be more than one part in 10,000. It is very unlikely that the sampling is going to be accurate enough... | Can htop show more than 4 characters of CPU% data? |
1,654,992,595,000 |
I've created a quantum-random number generator as part of my thesis and I'm trying to test it using the Dieharder test suite.
However, I still seem to get a few weak results (not reproducibly on the same test) even though I'm using -a -y 1 -k 2 as my options.
The man page indicates that -y should resolve ambiguities t... |
According to the manual, the flag to resolve ambiguity is -Y 1, not -y 1, which passes a parameter to the running test. Judging by that, you probably want -a -Y 1 -k 2, not -y.
(Disclaimer: I've never used the tool in question, this is just from reading the manual page.)
| Dieharder weak results even with RA mode |
1,606,501,408,000 |
I want to join two files on a Linux machine. I want to join the lines only included in the first file.
First file is unzipped file (no header, only one column).
1_4
3_4
4_63
6_2
Second file is gz file (with header, 16 columns).
CHR POS rsid SNPID Allele1 Allele2 AC_Allele2 AF_Allele2 imputationInfo N BETA SE Tstat p.... |
You have one error that means you will miss the first line from file2. You have both sed 1,1d which will delete the first line, the header, but also NR>1 in the awk which will again skip the first line. You probably wanted this instead:
join -11 -21 <(cat file1 | sort -k1,1) \
<(zcat file2.gz | awk 'NR>1{... | How to join two files in linux? |
1,606,501,408,000 |
I have a file named file1 with information like below:
TCONS_00000011 XLOC_000003 - u q1:MSTRG.39|MSTRG.39.9|4|0.000000|0.000000|0.000000|7468
TCONS_00000012 XLOC_000004 - u q1:MSTRG.41|MSTRG.41.1|2|0.000000|0.000000|0.000000|1270
TCONS_00000013 XLOC_000003 - u q1:MS... |
This is probably what you want:
awk 'NR==FNR{a[$1]; next} $2 in a' file2 file1
| How to get all the matches from a file based on names in another file? [duplicate] |
1,606,501,408,000 |
stty -echo; cat -v; stty echo is a technique to see what key you send to terminal. But I just wonder how this command work? When I remove stty -echo it will print twice what you typed in. I know stty -echo is disabling terminal printing you type. More specifically, my quest is "why can I use ';' connect commands to ac... |
; just separates commands so they are run one after the other.
Here, if you enter that at the prompt of an interactive shell, the terminal device local echo will have been disabled and reenabled by the time you you get back to the prompt as long as you exit cat normally (with Ctrl+D twice, or on an empty line).
If cat... | How does `stty -echo; cat -v; stty echo` work to echo special keys? |
1,606,501,408,000 |
I'm using scanimage --batch-prompt command to scan multiple documents one by one. That way it will ask to confirm scan for each page including first one.
Problem is, my usual use case is to launch that command when I've already placed first page in scanner and I want it to be processed without pressing any keys. Is it... |
Scanimage does not have such an option.
With a simple bash function, you can provide the first enter with an echo and wait for the other enters with cat. That is what
echo;cat
does. You can test this with:
(echo;cat)|sed 's/^/START/;s/$/END/'
So that is fed into the STDIN of scanimage.
| Automatically scan first page with scanimage in batch mode |
1,606,501,408,000 |
I was newbbbie of crontab command, and while i was investigating this command, i suddenly type some number and made my crontab -e look like this:
pi@raspberrypi:~ $ crontab -e
no crontab for pi - using an empty one
889
is there any way to set crontab back to default or how to delete them? i just want use crontab t... |
Your editor is set to ed. The ed editor is a very basic line editor which will output the number of bytes in the file when you open it. In this case, you crontab file contains 889 bytes (type ,p and press Enter in the editor to see the contents of the file).
You most likely don't want to use ed as you editor (or you... | Crontab -e simple problem |
1,606,501,408,000 |
I am trying to extract some info from a text block with markers like #@ and #@@.
Using the command below with the example file works, but when trying chain it with -e it does not work as expected.
Current command (not ideal)
sed -n "/^#@/,/#@@/p" file | sed 's/[#@]*//'
Reworked command ( does not work)
sed -en "/^#@... |
The command
sed -en "/^#@/,/#@@/p" -e 's/[#@]*//' file
will likely error out, because -en tries to apply expression n to file /^#@/,/#@@/p. If you want to combine -e with other options, you must put the expression argument after the -e like -ne "/^#@/,/#@@/p" or separate them completely like -n -e "/^#@/,/#@@/p"
Howe... | How to chain multiple sed commands properly |
1,606,501,408,000 |
I have a directory tree containing photos & videos, where I've "tagged" some information via the path. What I'd like to do is move all folders of a specific name into a separate folder, but reproduce the paths leading up to each instance of folders of that name. For example, starting with:
/Media
.../Pics
....../Trav... |
One thing you need to take into consideration before looking at the following answer is that you will effectively be recreating the whole path all the way from /
This will be a multi-step process, because you are looking to recreate the parent folder structure, and not precisely copy it and its contents. The structure... | Extract Folders With Certain Name To Parallel Directory Structure? |
1,606,501,408,000 |
I have the same question as this: configure error trying to install wgrib2 in mint: configure: error: C compiler cannot create executables
However, I am not sure how to solve the issue. I am not overly familiar with Linux.
Here are the outputs from the same commands as the original post:
$ type -a cc
cc is /usr/bin/cc... |
Your problem is different than the mint Linux user. That
person was trying to use a compiler (icc) that was not installed.
Intel C compiler (icc) is not a generic name for a C compiler
that compiles code for an Intel cpu.
You are on a MacOS, and are having a problem compiling the AEC library.
You should try the real g... | configure error trying to install wgrib2 |
1,606,501,408,000 |
I've installed exa via cargo and added the path to my ~/.bashrc file: PATH=/root/.cargo/bin:$PATH as per the post-installation instructions:
warning: be sure to add /root/.cargo/bin to your PATH to be able to run the installed binaries
Despite this, when I try to run exa I am met with
Command 'exa' not found, did yo... |
If sourcing the path isn't working it's likely a permissions issue. The sudo version uses a different PATH variable since you are running as root so while permissions aren't an issue you can't find the binary in the path.
For a user to "path through" (I'm not sure the technical term for that) a directory, they need to... | Command 'exa' not found |
1,606,501,408,000 |
Suppose i have two applications called firefox and arduino. At first, I typed firefox to the terminal and i still can use the terminal as usual. But when i typed arduino , i couldn't use the terminal anymore and i had to put it as background process. So, What are the difference between them?
|
It depends on how the program is started. There are various modes in which an application can be started, a couple of them relevant to this question are Daemon mode and Foreground mode.
I think when you start your Firefox, the application by default is started as daemon, in daemon mode the application sliently starts ... | Why sometimes when i run a program in terminal, it won't run in the terminal? |
1,606,501,408,000 |
I am pasting my output of the shell script
for i in `cat disk.txt`; do
echo Server:$i
ssh -q -i ~/production_private_key.pem $i "df -h --output=source,size,used,avail,pcent| grep -v tmp"
done
below.
I need to print the above output to different columns like as below.
Server IP | File System | Total Size | ... |
Add the IP for each line using xargs:
echo 'Server IP | File System | Total Size | Used Space | Available Space | Percentage'
for i in ...; do
ssh -q -i ~/production_private_key.pem $i "df -h --output=source,size,used,avail,pcent \
| tail -n+2 \
| grep -v tmp" \
| xargs -I{} printf '%s %s\n' "$i" {}
d... | I need to print output of a shell script in to separate columns |
1,606,501,408,000 |
I installed PyCharm Professional from the Ubuntu Software Store. I am using Ubuntu 20.04 although I don't think that matters much here.
I can't use it in the command line. I can't happen to find where it's installed so that I can add the executable launcher to the path. It is working absolutely fine but I'm habituate... |
Pycharm is installed as a snap in Ubuntu 20.04. Typing pycharm-professional from the cli should launch it. Otherwise you can launch using the full path:
$(mount | grep pycharm | awk '{ print $3 }')/bin/pycharm.sh
On my system the full path is /snap/pycharm-professional/198/bin/pycharm.sh. Yours will be slightly diffe... | What is the path of PyCharm in ubuntu when installed from the software store? |
1,606,501,408,000 |
This is my setting logrotate
/home/sy/logs/kitxit*/*/tend.log
{
daily
rotate 10
dateext
compress
delaycompress
copytruncate
missingok
notifempty
su apache apache
}
Output is like below
drwxr-xr-x 2 apache apache 4096 Apr 30 13:00 .
d... |
The log files in the debug output do not correspond to the logrotate path in the configuration file.
Files matching tend.log in the debug output
considering log /home/sy/logs/kitxit2/bola/tend/tend.log
considering log /home/sy/logs/kitxit/clpl/tend/tend.log
considering log /home/sy/logs/kitxit/mol/tend/tend.log
consid... | Why am I still seeing old log files and not having new ones? |
1,606,501,408,000 |
This is my first time asking a question. I am newly trying to use command line more and more but this problem is beyond my skill.
I want to do a multi part file transfer.
1) I want to take multiple files file_1.md, file_2.md...etc, from original_folderand copy them to target_folder_master
2) I want to take each file, ... |
Try this:
for file in *.md; do
mkdir "/path/to/target_folder_master/${file%.*}"
mv "$file" "/path/to/target_folder_master/${file%.*}/index.md"
done
| Copy Files from one directory to another while creating a new folder for each file, named after the file |
1,606,501,408,000 |
On Windows this is quite easy using Process Hacker. Suppose I want to know how many megabytes my torrent client has recieved and sent on Linux. How would I do this?
|
You could use nethogs, but it only accumulates statistics since you started it. So if you combine with screen or tmux you could leave it running between terminal sessions and occasionally check it.
In this answer nethogs is used in trace mode, which you could output to a logfile and also keep running. Then you could j... | Network stats for a program |
1,606,501,408,000 |
I have the following directory structure:
top_dir
|________AA
|_______f1.json
|_______f2.json
|________BB
|_______f1.json
|_______f2.json
|________CC
|_______f1.json
|_______f2.json
I would like to write a script / command line com... |
Using a loop:
mkdir /path_to/new_dir
cd /path_to/top_dir
for i in */*.json; do
cp "$i" "/path_to/new_dir/$(basename "$i" .json)_$(dirname "$i").json"
done
$(basename "$i" .json) prints the filename without suffix, e.g. f1
$(dirname "$i") prints the directory name, e.g. AA
| Copy files with the same name but in different dirs into a new dir while renaming them |
1,606,501,408,000 |
I am facing problems running two commands one after another in bash.
When I run
source2() { '/home/ds/Documents/scripts/Untitled Document 1.sh' && imgpath="$(ls | grep "^unsplash")" }
source3() { '/home/ds/Documents/scripts/Untitled Document 2.sh' && imgpath="$(ls | grep "^1920x1080" | shuf -n 1)" }
source4() {... |
Syntax issues aside, it's how you're calling eval:
$(eval $(shuf -n1 -e "${SOURCES[@]}"))
The outer $(...) mean that the eval happens inside a subshell, then the current shell takes the output and executes that as a command.
Because eval runs in a subshell, the contents of the variable will disappear with the subshel... | Run two commands one after another in bash, via a function, called with `eval` |
1,606,501,408,000 |
I want to generate a list of file names containing n=1 to k, add the string "cat output xyz.pdf" at its end and pass the result as parameter to pdftk. It should execute as this:
pdftk file1.pdf file2.pdf file3.pdf cat output xyz.pdf
How can I automate this directly in the CLI?
|
If you are using bash as indicated by your question tag, there's no need for a loop: you should be able to use brace expansion.
Ex. for k = 32
pdftk file{1..32}.pdf cat output xyz.pdf
If the number of files is very large, this approach may become limited by ARG_MAX (resulting in an "argument list too long" error).
| Generate parameters for pdftk with loop in bash |
1,606,501,408,000 |
Suppose I have a Apache/Haproxy log:
Jan 28 15:45:18 lict haproxy[48318]: 103.133.5.14:52243 [28/Jan/2020:15:45:08.730] LICT_front~ LICT_back/web2 9320/0/0/212/9532 302 556 - - --VN 24/24/4/1/0 0/0 "POST /exam/Users/login HTTP/1.1"
Jan 28 15:45:19 lict haproxy[48318]: 37.111.205.140:23757 [28/Jan/2020:15:45:19.355] LI... |
You could match the 11th record with awk:
awk '$11 ~ /^[45]0/' logfile
Or you could grep for the preceding five numbers separated by '/' plus a space character, the status code and another space character (see HAProxy HTTP log format):
grep '[0-9]*/[0-9]*/[0-9]*/[0-9]*/[0-9]* [45]0[0-9] ' logfile
or
grep -E '([0-9]... | Filtering Apache log for errors codes |
1,606,501,408,000 |
In Section 2.3 Token Recognition under Shell Command Language, what does the io_here token refer to?
2.3 Token Recognition
The shell shall read its input in terms of lines. (For details about
how the shell reads its input, see the description of sh.) The
input lines can be of unlimited length. These lines shall b... |
The shell grammar defines io_here as
io_here : DLESS here_end
| DLESSDASH here_end
DLESS is <<, DLESSDASH is <<-, and here_end is the end-of-here-document marker.
So the io_here token is the token introducing a here-doc.
| What is the "io_here" token in the Shell Command Language referring to? |
1,606,501,408,000 |
Regarding mapping function keys in vi readline, I have read these two stackexchanges:
Remap bash vi keys?
Custom key bindings for vi shell mode, ie, "set -o vi"?
I have a MacBookPro with a touchbar. The function keys are always on, but unlike physical keys, the virtual touch bar function keys are tempermental and ... |
This is insane but true...i was on a new server today and having forgotten completely about this question (and the answer buried in comments), I was actually googling for how to do this today. I'm posting my answer for myself or for anyone else that is having problems disabling function key input in vi commandline:
... | How do I remap function keys in readline bash vi (vi shell mode)? |
1,606,501,408,000 |
I wrote an alias for cross-compiling.
alias cross_compile="make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- -C /home/jamal//buildroot-2019.05/output/build/linux-4.19.16 M='$PWD' modules"
But the PWD is not being evaluated each time i call cross_compile from terminal, it is set to a static directory.
How can i make s... |
You need to invert all single-quote to double-quote, and all double-quote to single-quote. This defers the expansion of PWD until the alias is invoked. Shortened example:
Paul-) alias cross_compile='echo linux-4.19.16 M="${PWD}" modules'
Paul-)
Paul-) alias cross_compile
alias cross_compile='echo linux-4.19.16 M="${P... | alias for cross compiling kernel module |
1,606,501,408,000 |
I have two web servers, and I want to know the top 10 ips sorted by the number of requests.
The webservers are Apache based, so I need to look at an access.log file.
The problem is since these files are huge, I really wish to not transfer them locally, thus I would like to know if there is a way to do this in streamin... |
Since the concern is only with the filesize conceptually all that is needed is
{
ssh server2 cat /path/to/access.log
cat /local/path/to/access.log
} | awk '{print $1}' | sort | uniq -c | sort -n | tail
however there are a number of things that can be done to improve the speed.
First only send the ip addresses across ... | Top 10 IP by request across two nodes |
1,606,501,408,000 |
I'm running kali linux and until I was using the root account, everything was fine, but then I made a personal account (name: koumakpet) and used that terminal instead of
koumakpet@kali: ~$
there was only
$
As you can see in the image, I was trying to change my prefix by PS1='prefix' but that didn't went quite as... |
That PS1 syntax is specific to the bash shell.
Presumably, that new user has been assigned a different login shell.
Use chsh to change the login shell to /bin/bash (and logout+login again), or adapt that PS1 syntax to that of user's login shell.
ps shows the shell in question is sh. I suppose that's the default shell ... | How to setup a terminal prefix |
1,606,501,408,000 |
It happens quite often to me, that while entering a complex command I realize that I need to enter some other commands first.
Being a vi user, I'd love to 0 D, enter a different command and later paste the deleted command line. Unfortunally, nobody (including myself) bothered to implement c&p-Registers in the vi mode ... |
Enable the interactivecomments shell option with
setopt interactivecomments
and use the # action in normal/command mode on the command line (i.e. press Esc followed by #).
This inserts a # in front of the line, immediately submits the line (which will be ignored since it's a comment), and adds it to the command line ... | zsh with vi-mode: How to keep a command line for future use without executing |
1,606,501,408,000 |
I am trying to get the same functionality as on a Linux where the last argument can be inserted into a another command easily.
|
If you're using bash or zsh, the shortcut !$ works in the same fashion.
For example:
[user@localhost ~]$ echo "test" >> new_file
[user@localhost ~]$ cat !$
cat new_file
test
| Whats the equivalent of the Linux Alt + '.' on MacOS? |
1,606,501,408,000 |
I'm installing Nvidia drivers and have to click through screens like this (not this specific screen, but this is the installer and has some OK and some Yes/No questions during install):
Is there a way to automate this? (my goal is to eventually do this via puppet)
|
Yes, I've done this before. Took me a few days to get it to work.
NVIDIA.....run -s for silent mode.
I found this option by using the Advanced help feature:
./NVIDIA....run -A
Note: Run it manually and choose all of the defaults to be sure that this is what you want (usually, that will be the case).
Caveat: The mac... | How to automate selections when installing via CLI |
1,570,313,247,000 |
So, i installed i3 with the wrong commands on my mint 19.2 with xfce4 and got a broken version and since my system is set for "open without the account screen" its stuck there, i3 only showed me some error at status and nothing else, fixed it with sudo apt-get update && sudo apt-get install i3-wm i3status i3lock suckl... |
The default i3 key bindings should be active. To go back to xfce, exit i3 with the keyboard combination ALT+SHIFT+E
That should log you out and take you to your display manager. From there you can select xfce and log in.
| Stuck in broken i3 wm and don't know how to get it back to xfce |
1,570,313,247,000 |
So, I have a file with a list of names, like
Thomas Newbury
Calvin Lewis
E. J. Frederickson
Lamar Wojcik
J.C. Lily
Lillian Thomas
And I'm eventually going to try and split these into a long list of first and last names, but before I do that, I want to turn "E. J." into "E.J." and I'm having trouble figuring out how ... |
I think this will do with GNU sed:
sed -E 's/^([A-Z]+\.)[[:blank:]]([A-Z]+\.)/\1\2/' file
| removing a character in a certain context (using shell script) |
1,570,313,247,000 |
I have a directory which contains a huge number of XML files.
They are labelled as filename_date_time_checksum.xml, which means I've got thousands of files which are identical but separated by checksum.
Is there a command line I can run where if filename_date_time_*.xml exists, then retain the last modified version a... |
This is untested:
# find the *latest* file for each prefix
declare -A mtime name
stat -c "%Y %n" *xml |
while read -r time filename; do
prefix=${filename%_*}
if (( $time > ${mtime[$prefix]:-0} )); then
mtime[$prefix]=$time
name[$prefix]=$filename
fi
done
# put the filenames into an associ... | Linux command-line to find duplicate files and only retain most recent |
1,570,313,247,000 |
A user can execute an executable by : sudoing which allows a user to run an executable as the owner or by setting the execute bit, chmod u+x (or should it be chmod a+x ?).
So what is the real difference between the two given that they have the same effect, that is, to allow someone else than the owner to run the execu... |
I suspect you meant to ask specifically about chmod o+x, to enable other (i.e. someone who is neither the user nor a member of the specified group) users to execute the file. chmod a+x is a superset of chmod o+x since it turns on the execute permission for all 3 (user, group, and other).
The difference then is the con... | Difference between chmod +x vs sudoing an executable |
1,570,313,247,000 |
my file.txt looks like this
variant_id pval_nominal
1_752721_A_G_b37 2.23485e-05
1_900397_C_T_b37 3.04603e-05
1_928297_G_A_b37 2.12455e-05
I am trying to remove everything after the 2nd underscore in the first column so that it looks like this:
variant_id pval_nominal
1_752721 2.23485e-05
1_900397 3.04603e-05
1_92829... |
Try this,
sed 's/_[A-Z].* / /g' file
variant_id pval_nominal
1_752721 2.23485e-05
1_900397 3.04603e-05
1_928297 2.12455e-05
| How to remove everything after the 2nd underscore but keep the other columns? |
1,570,313,247,000 |
I want to pass a string in hexa :
'c3:87:80:00'
by instance to a binary
I've tried :
./<bin> "$(python -c "print 'c3:87:80:00'")"
and
./<bin> "$(printf 'c3:87:80:00')"
I've also copy paste the string result of it from an hexa converter but it doesn't work better
|
Replace \xc3:\x87:\x80:\x00 instead of c3:87:80:00.
Where \x represent hex data
| pass a string with non printable char in hexa to a |
1,570,313,247,000 |
Trying to insert output from this:
kubectl get pods | grep -Eo '^[^ ]+' | grep portal
Into this:
kubectl exec -it <here> portal bash
Tried:
kubectl exec -it `kubectl get pods | grep -Eo '^[^ ]+' | grep portal ` portal bash
But no luck.
|
kubectl exec -it "$(kubectl get pods | grep -Eo '^[^ ]+' | grep portal)" bash
Or, even more:
kubectl exec -c portal-container -it "$(kubectl get pods | grep -Eo '^[^ ]+' | grep portal)" bash
| Pass command-line result as an argument to next command |
1,570,313,247,000 |
I'm trying to concatenate multiple files together that are in different directories using the following command:
~$ find . -name ‘*.text’ -exec cat {} >> combined.text \;
However it doesn't seem to be working as I am getting a response as:
find: missing argument to `-exec'
Is there something that I have may missed?
... |
You are using unicode quotes: ‘’ instead of normal quotes (''). Try this command instead:
find . -name '*.text' -exec cat {} + >> combined.text
However, if combined.text already exists, that will print a warning since combined.text will be created before launching find so will be found by the find command:
$ find . ... | Can't seem to concatenate multiple files in different directories |
1,570,313,247,000 |
I have a private key file with some extra nonsense in there, and want just the text of the key.
so:
nonsense -----Begin Key-----
keep this1
keep this2
keep this3
-----End Key----- nonsense
should become
-----Begin Key-----
keep this1
keep this2
keep this3
-----End Key-----
EDIT: I don't want to just remove the ac... |
How about
sed -e '/Begin Key/ s/^[^-]*//' -e '/End Key/ s/[^-]*$//'
Ex.
$ sed -e '/Begin Key/ s/^[^-]*//' -e '/End Key/ s/[^-]*$//' file
-----Begin Key-----
keep this1
keep this2
keep this3
-----End Key-----
| SED or AWK to remove everything before the first dash and after the last |
1,570,313,247,000 |
I have the file dir1.txt that contains the names of the following directories:
2
3
4
Directory 2 contains files 2_1.txt and 2_2.txt
Directory 3 contains files 3_1.txt and 3_2.txt
Directory 4 contains files 4_1.txt and 4_2.txt
Each file contains two lines.
Then I have created the following nested loop:
#!/bin/bash
inp... |
Your logic is correct, but I had to make a few modifications to get it working.
Added a missing space after IFS (otherwise error)
Changed the quoted "$line/*" to "$line"/* (otherwise sed: can't read 2/*: No such file or directory)
Quoted $j (only for better style)
Both the sed and the cat/echo version do what they s... | Concatenate the Content of Files from Various Directories with a Blank Line in Between |
1,570,313,247,000 |
I have deleted a user using userdel command, but I forgot to delete user files. Now I want to delete those files, how can I find and delete them?
|
If you have ways of finding the userid they used to have (for example because you have one file/directory you know they owned, like their home directory), you can use
find / -uid (userid)
to find all files owned by that user id. You could use find / -uid (userid) -delete to delete them all, but I strongly advise agai... | Deleted a user but forgot to delete home directory and user files |
1,570,313,247,000 |
How does one combine two commands like the ones shown below into one command with one output file?
first command:
printf '%s\n' {001..500} input > output
second command:
sed 's/^/PREFIX /; s/$/ SUFFIX/' input > output
|
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf command.
printf 'PREFIX %s SUFFIX\n' {001..500} > output
(I'm not sure if the input part should be there. It's absent in your answer.)
| How to combine two text formatting commands into one? |
1,570,313,247,000 |
I'd like to open a URL in the default internet browser from my application. My application gets compiled for MS-Windows, Linux, Mac and Solaris.
One way to achieve that on Windows is using the shell command start, on Linux using the xdg-open, on Mac there is open. As a bonus, all these commands can also open any file ... |
sdtwebclient will be installed under /usr/dt/bin if CDE is installed, which limits it to Solaris 10 and older machines.
For Solaris 11 and later, use xdg-open just as you would on Linux.
| How to start the default browser (and/or any default application) from command line on Solaris? |
1,570,313,247,000 |
So I am trying to figure out how to add a title after the timestamp in my xclip script here. I would like it to grab about 24 characters worth of text from the beginning of each selection and save it like:
$timestamp_$24-character-long-title-of-start-text.txt
Or instead of start text, would it be possible to have it g... |
I use this script to save all kinds of useful text clips, code snippets, useful articles, everything from all over the web. It saves in drive space and is a super fast and easy way in doing so.
This allows me to come back to the information later in the event I want to see or go through it again.
However, just using ... | How to grab x characters long of start text from xclip selection and append to filename? |
1,570,313,247,000 |
While I working on a script I need to print available SSID only.
I tried this:
sudo iwlist wlp2s0 scan | grep ESSID
I got output like this:
ESSID:"CoreFragment_5G"
ESSID:"dlink"
ESSID:"REDWING LABS"
ESSID:"Hitachi"
ESSID:"COMFAST"
... |
There are many ways to do it, using awk:
sudo iwlist wlp2s0 scan | grep ESSID | awk -F '"' '{print $2}'
Or using cut:
sudo iwlist wlp2s0 scan | grep ESSID | cut -d '"' -f2
These commands will give you the names without ".
| How to print SSID only? |
1,570,313,247,000 |
I'm reviewing a repo and I'd like to make some comments, it would add more content like adding comments, make some changes ..etc.
How to change content of files of previous commit and do push, I'm aware that commit history would be changed and all affected files would be changed also, but would git compare the affect... |
What you are asking for is to rewrite history n to 0 commits back. This is generally a bad idea as it would make you repo out of sync from the remote and any other repo that is based on it. This would further complicate things so that others wouldn't be able to merge anymore and would require any other repo to delet... | Git: change content of previous commit and push [closed] |
1,570,313,247,000 |
I am truing to run maitreya_textclient (an application to list astrological information in text mode) and I get the following error:
WARN: datadir does not exist
Fatal error: cannot open Yoga config directory /usr/share/maitreya6/../xml/yogas
On Debian "testing" repository Maitreya comes as version: 7.0.7-1+b1
so it ... |
Although posting a bug report would be best, in the interim you could try fixing up the broken directory paths to point the missing version 6 directory at the version 7 one that exists
cd /usr/share
ln -s maitreya7 maitreya6
I can't test this, though, so I don't know if you'll find your yogas in there at the right pl... | Maitreya 7 error: linked to "config directory /usr/share/maitreya6/" |
1,570,313,247,000 |
For curiosity, I wanted to read a GNU screen session's named pipe.
$ screen -ls
There is a screen on:
59750.hello (Detached)
1 Socket in /var/run/screen/S-gergely.
And indeed there is a named pipe:
S-gergely $ ls -l
összesen 4
prw-------. 1 gergely gergely 0 nov 21 11.06 59750.hello
I tried to read it with... |
When data was read from pipe it was gone from pipe. I don't think that it's possible to have multiple readers which can read same data at same time. So when screen is attached, probably screen process read data before tail/cat that you use.
| How to read screen's named pipe? |
1,570,313,247,000 |
Is there any nice single line command to revoke all the user's privileges (read/write permission on each account) except a user executing the command and root?
I want this because I want to restrict all the access from all users at specific time point. Of course, I can do this with commands such as chown and chmod, bu... |
NOTE: if you are thinking about this because you think your system has been hacked or something else unlawful is going on in it, stop reading this and search using keywords "linux gathering forensic evidence".
There are some special steps you should follow if you need to absolutely "freeze" the state of a system for ... | Revoke all users's privileges (read/write on their home directory) except a user executing the command and root |
1,570,313,247,000 |
I went to open my terminal and it said this:
Gillians-iPhone:~ milo$
I know for a fact that this is not my computer name. I am running mac osx 10.13.4. I am on a public wifi network at a hotel. This just recently started happening. I set my laptop up as Milo’s MacBook Air.
|
You have got the name of the hostname of the previous user by some DHCP behaviour.
I would not be surprised that after a while, depending on the Wifi setup, that your name comes back to normal.
Nonetheless, one strategy to minimize this, in the present, and in the (near) future, is to configure the DHCP service to (tr... | Terminal showing different name |
1,570,313,247,000 |
I check the manual of mpstat it states:
The mpstat command writes to standard output activities for each available
processor, processor 0 being the first one. Global average activities among
all processors are also reported. The mpstat command can be used both on SMP
and UP machines, but in th... |
It's unclear exactly what the M in mpstat means. NOTE: mpstat is part of the sysstat package and so is part of a family of *stat tools:
$ rpm -ql sysstat | grep /bin/
/usr/bin/cifsiostat
/usr/bin/iostat
/usr/bin/mpstat
/usr/bin/nfsiostat-sysstat
/usr/bin/pidstat
/usr/bin/sadf
/usr/bin/sar
/usr/bin/tapestat
It's likel... | What does "m" mean in mpstat? |
1,570,313,247,000 |
Is it possible to run an opengl application like glxgears from the command line without starting a desktop environment?
It should directly go to exclusive full screen mode.
|
It is not possible to run an application meant for X in the command line.
But like @cylgalad said, you can have any desktop environment and put that application to run exclusively.
Try to install a lightweight desktop environment, like xfce or fluxbox.
| Running OpenGL app without desktop |
1,570,313,247,000 |
No matter what directory I enter, the terminal always shows me the root directory which is "Nidas-MBP"
Nidas-MBP% cd Projects
Nidas-MBP% ls
09-Selector-Exercise-Starter.zip My Little Form
09_Selector_Exercise_Starter Prefix Free File
Blog Recursion Practice
Callbacks ... |
I had no idea there was a difference in commands between bash and zsh. Apparently, I was supposed to type PS1='%m %1d$ ' instead. So I did that inside the ~/.zshrc file and it works now.
https://superuser.com/questions/1108413/zsh-prompt-with-current-working-directory
| My MacOSX terminal doesn't show the current directory |
1,570,313,247,000 |
we have script that print all bad wsp files
./print_bad_wsp_files.sh
./aaaa/rrr/aaaa/fff/ooo/min.wsp
./aaaa/rrr/aaaa/fff/ooo/p50.wsp
./aaaa/rrr/aaaa/fff/ooo/min.wsp
./aaaa/rrr/aaaa/fff/ooo/p50.wsp
# ls -ltr
drwxr-xr-x 5 root root 36 Aug 14 14:58 aaaa
is it possible to pipe the script so I will get the ls -lt... |
All you may need here is xargs:
./print_bad_wsp_files.sh | xargs ls -ltr
xargs will read the output from the script and execute ls -ltr on all of them (potentially grouped in bunches, as many as will fit in each call to ls).
Note that if there are multiple calls to ls, each ls will sort its own list of files (by reve... | how to pipe ls -ltr after list of files to capture date and time |
1,532,672,904,000 |
Could you please explain what each option on this ls command does: ls -td -- */?
The result of such command would look like below:
$ ls
$ ls -al
total 4
drwxr-xr-x 5 root root 68 Jun 4 09:58 .
drwxrwxrwt. 13 root root 4096 Jun 4 10:05 ..
drwxr-xr-x 5 root root 36 May 31 15:48 05-31-2018
drwxr-xr-x 5 root r... |
-td is the two options -t and -d written together. -t tells ls to sort the output based on time, and -d asks to show directories named on the command line as themselves, instead of their contents.
The -- option is as far as I know not explicitly documented for many commands that do support it and it has become a sligh... | What is -- and -td options on ls command? |
1,532,672,904,000 |
I'm working in a method of splitting a single large PDF file (which represents monthly settlements of a credit card). It is builded for printing but we'd like to split that file into single ones, for posterior use. Each settlement has a variable lenght: 2 pages, 3 pages, 4 pages... So we need to "read" each page, find... |
I've made it. At least, it worked. But now I'd like to optimize the process. It takes up to 40 minutes to process 1000 items in a single massive pdf.
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to multiple pages based on search criteria while renaming the output files using the search criteria and s... | Splitting a single large PDF file into n PDF files based on content and rename each splitted file (in Bash) |
1,532,672,904,000 |
I'm using an CLI Arch Linux and I want to run an Shell/Bash Script to show the status of my Battery with acpi directly on the String Prompt(PS1).
I create the following Shell Script to Show me the Battery Status:
# Permition Acess: chmod +x loop.sh
# run .sh: ./loop.sh
i=true
#COLOR:
ORANGE='\e[33m'
STOP='\e[0m'
whi... |
there is no portable way to do what you want, but a shell specific method will probably work.
The prompt variables (PS1, PS2, etc.) have two specific and distinct types of evaluation that is mostly portable: assignment expansion which is exactly like any other variable assignment expansion which will allow for subcomm... | CLI Battery Status Update on Prompt |
1,532,672,904,000 |
I have many files in my directory. I'd like to listing, copying or moving file containing 'abc' AND 'xyz' in their name. How do I do this pattern matching with AND?
The normal command: ls *abc* *xyz* only work with OR.
|
Use this way.
ls *abc*xyz* *xyz*abc*
Using in mv or cp, you just need specify the target directory with -t option since you are looking the files with wildcards and can be more than a file to copy/move:
cp -t /path/to/dest *abc*xyz* *xyz*abc*
Or use find like:
find \( -name '*abc*' -a -name '*xyz*' \)
which is same... | Matching many pattern in file listing command ls? [duplicate] |
1,532,672,904,000 |
I have just started learning unix and came across very basic doubt in command line arguments.
Suppose if in my script i do:
echo $@ #Now this prints all the command line arguments
args=$@ #Args array will take the command line argument array from $@
echo $args
Here i have doubt in last statement. echo arrayname as... |
It's printing every element because you have set a variable and not an array. To set an array you would need to do:
args=($@)
| Basic doubt in echo statement |
1,532,672,904,000 |
Hi I got interest in a solution posted here & put the suggested function in a bash script leaving at ~/.bin so, a dir under path. Then performed $chmod +x verbteacher.sh for easy calling from $ anywhere in the command line but it does not work. I tried to, kind of, re-open the question & tried also the suggestion of f... |
If you want the conjugations (on link address, after /conjugations/ you may choose the language you want to, in my case I choosed french /fra/ ) values, write this on the last line of .bashrc:
conjfra () {
curl -s "http://api.ultralingua.com/api/2.0/conjugations/fra/$1" | jq -r '.[] | {tense: .conjugations}'
}
Me... | Looking for an e.g. bash solution to check English verb conjugation |
1,532,672,904,000 |
I'm trying to manipulate files in a directory whose filepath includes a directory that starts with "$", for instance:
git rm path/to/file/$dollarsigndirectory/anotherdirectory/file.format
I'm getting the following error:
fatal: pathspec 'path/to/file//anotherdirectory/file.format' did not match any files
EDIT: I've... |
You can surround the path with single quotes so that the $ is not expanded.
| macos - terminal deleting parts of filepath beginning with "$" [duplicate] |
1,532,672,904,000 |
I was trying to follow this tutorial: https://www.shellhacks.com/check-website-availability-linux-command-line/
When using the curl -Is http://www.shellhacks.com | head -1command, I am unable to get 200 OK for any website at all. It is either 302 Moved Temporarily, 301 Moved Permanently or 307 Temporary Redirect. I am... |
Actually you are able to obtain 200 OK HTTP response, but you can't eventually see it with head -1. The crucial option is -L:
-L, --location
(HTTP/HTTPS) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will ... | Can't get 200 OK when checking URL? |
1,532,672,904,000 |
Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?
the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors wh... |
Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.
function ls {
if [ -t 1 ]
then
command ls -F "$@"
el... | Coreutils (or otherwise) `ls`: don't append symbol indicating type when piped |
1,532,672,904,000 |
I am working on some tshark filters , need to split a pcap on timebasis for particular SIP and DIP, I have tried editcap but it can go with time basis only I cannot pass IPADDRESS to editcap, I saw tshark can do this [root@ids01 snort-1]# tshark -r snort.log.1518688921 -w /tmp/pcap_tshark.pcap -Y "(frame.time >= "" F... |
The problem is with usage of quotes, you need backslash to preserve double quote of the filter, try this:
tshark -r snort.log.1518688921 -w /tmp/pcap_tshark.pcap -Y '(frame.time >= "Feb 17, 2018 16:00:00") && (frame.time <= "Feb 17, 2018 16:01:00") && ip.addr==192.0.0.7'
or this which also permits to use variables i... | tshark filters in Centos 7 |
1,532,672,904,000 |
How do I delete lines after "/test1/end" that does not contain test1
test_long_sentence.txt:
20 /test1/catergory="Food"
20 /test1/target="Adults, \"Goblins\", Elderly,
Babies, \"Witch\",
Faries"
20 /test1/type="Western"
20 /test1/theme="Halloween"
20 /test1/end=category
**This is some unwanted data blah blah blah... |
Try:
$ awk '/test1/{f=0} !f{print} /test1\/end/{f=1}' sentence.txt
20 /test1/catergory="Food"
20 /test1/target="Adults, \"Goblins\", Elderly,
Babies, \"Witch\",
Faries"
20 /test1/type="Western"
20 /test1/theme="Halloween"
20 /test1/end=category
20 /test1/Purpose=
20 /test1/my_purpose="To create
a fun-filled... | Delete line after keyword1 if keyword2 does not exist |
1,532,672,904,000 |
As I understand bash is a program like python interactive shell, which receives command(or commands) by input stream, executes them by calling Linux API functions, and give execution result to output stream.
Terminal is also a program that provides us some features like command history and highlighting, internally it ... |
Yes, programs may well use the shell, either explicitly or implicitly.
See e.g. Stéphane's answer to an unrelated question.
Their answer says, for example, that if the program uses the C library functions execlp() or execvp() to run a command, upon execve() returning ENOEXEC it will typically invoke sh on it ("it" bei... | Do programs like Nautilus uses shell? |
1,532,672,904,000 |
For my systems programming course, I'm supposed to go through a piece of sample text and replace the most frequent word with another phrase. Unfortunately, I am only allowed to use the commands
tr
grep
egrep
sed
awk
uniq
wc
as well as piping. I have gotten so far as to find the most frequent word and wish to use it i... |
You most likely don't want to use tr to do that, as tr only works on individual characters (or bytes):
$ echo abc | tr cab taxi
axt
I would recommend taking a look into sed and especially the s/// (substitute) operator instead.
As for passing the output of a program to the command line of another, the keyword is com... | Using the output of a command as a set for tr |
1,532,672,904,000 |
I am trying to get the distribution name and version number to enter into conky. I am currently using the following
rpm --query centos-release
resulting in
centos-release 7-4.1708.e17.centos.x86_64
How do I pare that down to just centos 7-4.1708.e17?
After trying all the suggestions I ended up entering this into my... |
With sed:
$ rpm --query centos-release | sed 's/^centos-release//;s/\.centos.*//'
7-4.1708.e17
With only shell:
#!/bin/sh
a=$(rpm --query centos-release)
a=${a#centos-release }
a=${a%%\.centos.*}
echo "$a"
| bash command to get distribution and version only |
1,532,672,904,000 |
I've logged into my GoDaddy server through PuTTY, I'm connected as ted67942 which is not the root user. I'm trying to run basic commands like sudo, dpkg, su, etc. but they all return the "command not found" error. How do I either fix this or log in as the root user? I'm trying to install mod_reqtimeout on my webserver... |
GoDaddy seems to provide a somewhat restricted environment which does not include unlimited root access.
According to GoDaddy documentation, the WebHost Manager (WHM) GUI includes a feature called "EasyApache (Apache Update)".
Within EasyApache, select the gear icon ("Customize Profile"), then "Next Step" and "Exhaust... | Run basic administrative commands on GoDaddy |
1,532,672,904,000 |
Is the CLUI (Command Line User Interface) and GUI (Graphical User Interface) utilize different TTYs or both of them share the same TTY?
I understood in the past that they both share the same TTY but I might be wrong. I got a bit confused when reading about that and saw different phrasings that made see the CLUI/GUI-... |
CLUI: command line user interface
GUI: graphic user interface
These things mean what they mean, no more.
These definitions don't include anything about a tty. For example, the cmd.exe on windows is also a CLUI, although it doesn't use any tty device (it is conceptionally nonexisting on Windows).
Tty means a virtual ... | Is the CLUI and GUI different TTYs? [duplicate] |
1,532,672,904,000 |
I'm having a hard time figuring how to pass the output of one command to another as an argument.
Specificly, I want to pass the list the extended attributes of a file in FreeBSD, with lsextattr, and pass its output to rmextattr to remove all the extended attributes. Yes, I need to do this because rmextattr don't have ... |
IIUC, rmextattr can only take one extended attribute at a time. So you will have to loop over the extended attributes that lsextattr returns and remove each one; something like this:
for attr in $(lsextattr -q user some_file.txt) ;do
rmextattr user $attr some_file.txt
done
(untested - I don't have access to a Fre... | How to pass the output of previous command to next as an argument |
1,532,672,904,000 |
I have this find command that compresses png files.
find /path/to/folder -mtime -1 -mtime +0 -exec pngquant --ext .png -v --force 256 {} \;
I've also tried using mmin like so
find /path/to/folder -mmin -1440 -mmin +0 -exec pngquant --ext .png -v --force 256 {} \;
The -1 and +0 in -mtime -1 -mtime +0 are variable, an... |
If it's in variable you could do as following.
find /path/to/src -type f -mmin -$((60 * $hourP)) -mmin +$((60*$hourN)) -exec pngquant --ext .png -v --force 256 {} \;
also better to use + in place of \; for exec termination operator to accomplish like pngquant a b c rather than pngquant ;pngquant b; pngquant c
For a... | Using mtime or mmin to find files in last day |
1,532,672,904,000 |
I have created a servicefile and I kept it in the /etc/systemd/system.
It is starting the service as a daemon at the start of the system.
I don't want it to start at the start of the system.
I want to start the service when I will run a command to start the service.
Thank You.
|
Extract from the Debian systemd documentation
Show status of the service "example1":
systemctl status example1
Enables "example1" to be started on bootup:
systemctl enable example1
Disable "example1" to not start during bootup:
systemctl disable example1
Start a Service example1
systemctl start example1
| How to start a service in linux after running command not at start of the system? |
1,532,672,904,000 |
Using "jbossapp" user I'm using this command to find ".stat" files which are created more than 3 minutes.
find /opt/jboss/* -mmin +3 -name "*.stat"
Recently there is a folder created in /opt/jboss/ directory with root user now while using this command I'm getting 'permission denied' from the particular folder which... |
Use
find /opt/jboss/* -type f -mmin +3 -name "*.stat" 2>/dev/null
The 2>/dev/null will redirect the Standard Error Output to special file /dev/null to avoid displaying any errors.
Also we add -type f to look for fIles only.
To excluding a directory use like below
find /opt/jboss/* -path /path/to/exclude -prune -o ... | How to find a file which is created after 5 mins exclude one sub directory which is owned by root user |
1,532,672,904,000 |
i am at fickurthe first one and trying to move the inner fickur to digital with only one command line, but cant seem to figure this one out.
here is what i have tried so far:
mv -v fickur/ ./klockor/armbandsur/digital
results:
mv: rename fickur/ to ./klockor/armbandsur/digital: No such file or directory
|
If you are inside the dir fickur (the rectangular one in the drawing), do
mv fickur/ ../armbandsur/digital/
| How to move a file from a subdirectory to another subdirectory located outside the first one? |
1,532,672,904,000 |
I have ten files text1.html...text10.html. There are numbers 1234567890 in each file.
How I can change 1234567890 with 0987654321 in each file from the terminal without opening files?
|
#!/bin/bash
for i in `seq 1 10`;
do
sed -i 's/1234567890/0987654321/' text$i.html
done
If you're lazy, here it is in a for loop. ;)
| Changing text from the Linux command line |
1,532,672,904,000 |
I am trying to add a right click menu to odrive, using nautilus-actions and the sync agent.
However, after setting the script up with the path "$HOME/.odrive-agent/bin/odrive" and parameters sync "%f" (Like shown in the documentation).
This does not work, and setting it to show output gives me
"$HOME/.odrive-agent/b... |
When using %f, don't add double quotes around it. Doing so will prompt the application to escape the double quotes in the string (that's where the backslashes comes from).
| Nautilus-Actions Is Adding Backslash |
1,532,672,904,000 |
I am looking for a command line tool that "converts" a pdf file (whose size is larger than a4) into a single pdf file that consists of multiple a4 pages. The new pdf file, when printed, should look like the original content without scaling the original.
Searching the internet, I found pdfposter. Yet, it seems to requi... |
I wrote a tool that can do what you want. I explained it over at askubuntu: https://askubuntu.com/a/1155892/394569
It's called plakativ and its main interfaces is a GUI. But it also has a command line interface that allows you to do what you want including specifying borders to glue the pages together.
If you find a b... | Command line tool to create a pdf file with a4 sized pages from a poster pdf |
1,495,530,814,000 |
For encryption i am using openssl aes-256-cbc -a -salt -in abc.txt -out abc.txt.encso now how to encrypt a file from my desktop where the file is in server like \10.113.123.15
|
If you have SSH access to the host:
$ ssh username@server openssl aes-256-cbc -a -salt -in abc.txt -out abc.txt.enc
This will connect to the host server as username and run the specified command.
The openssl command will write to standard output if no output file is specified, which means you may store the result in ... | How to encrypt a file which is on a server [closed] |
1,495,530,814,000 |
When opening files in Firefox from konsole, the autocomplete function only works for certain file extensions like html, htm and the like. For other extensions, I have to type out the full name instead.
How can I configure firefox (or konsole) to give me the same behavior for other files? Specifically I'm asking for md... |
It will depend on the shell you are using. For example for bash you will find completion functions inside the /etc/bash_completion.d directory. You probably have one regarding firefox listing the extensions it looks after, and you should change it to add your .md extension.
| Enable command line completion of *.md files for firefox in konsole |
1,495,530,814,000 |
As I was doing a project, I came to know about how command line can be read using ncurses and GNU's readline library. However I could not find either in Ubuntu (16.04). I am curious to know how Ubuntu processes the command as the user types? For eg: how does it detect up/ down arrow being pressed, how is Tab detected... |
Ubuntu the operating system does not read command lines. Some programs read command lines. For example, bash is a command interpreter (also known as a shell) which reads command lines. When the shell is interactive and reads command lines from a terminal it uses the GNU readline library.
$ sudo apt-get -y install libr... | How reading command line happens in Ubuntu [duplicate] |
1,495,530,814,000 |
how can I print difference line number?
example- compare File 1 vs File2 and print line no. for differnce record present in file 2.
In file1:
userD
user3
userA
user1
userB
and
In file2:
user3
userB
userX
user1
user7
expected result:-
difference in file2 is for line number 3,5
|
bash-4.1$ cat file1
userD
user3
userA
user1
userB
bash-4.1$ cat file2
user3
userB
userX
user1
user7
bash-4.1$ awk 'NR==FNR{Arr[$0]++;next}!($0 in Arr){print FNR}' file1 file2
3
5
| compare two files and print unmatched line number? |
1,495,530,814,000 |
sort -k 2 filename.txt means that it sorts by the second key but what would this following command mean: sort -k 3.3,3.5 for this data:
For example: I got this-->
Man in Winter England 1980.12.02
Richrd Fritz Scottland 1960.12.18
Max Winter GB 1955... |
Let's assume there are no tabs in the input. The interpretation of the command is pretty tricky:
sort -k3.3,3.5
means "sort by a substring from the third field from the third to the fifth character", but the counting begins at the first whitespace before the field, as mentioned in man sort:
KEYDEF is F[.C][OPTS][,... | sort command understanding the logical sequence |
1,495,530,814,000 |
I want to pipe part of a very large text file into downstream work (python).
Basically, I want get all the odd lines and first n characters of the even lines, but I still want to keep the line order.
The reason is that the even lines are very very long, but I only need first few characters. This can make reading the f... |
Here is a solution in awk:
$ cat testfile
foo
asdkjasjdka
bar
kjsdksjdkssd
$ awk -v n=2 'NR % 2 == 1 { print } NR % 2 == 0 { print substr($0, 1, n) }' testfile
foo
as
bar
kj
| pipe part of a text file into downstream work (python) |
1,495,530,814,000 |
With the cal command I noticed you can use:
cal -3
Which displays current month, one before, and one behind. Is there an easy way to show another number? The following doesn't work:
cal -5
Are the only options single month, 3 months, or full year? Or is there a simple way to show an amount of months above 3 but belo... |
I hate to answer my own question. It was so obvious after reading man cal.
cal -A 4
The above displays 5 months, but not in the same way cal -3 does (with current month in the middle). Instead it starts with the current month and adds 4 ahead.
| Display Set Number of Months with cal |
1,495,530,814,000 |
I'm maintaining a server which runs mailman. In it I find a crontab which looks like the following:
0 8 * * * list [ -x /usr/lib/mailman/cron/checkdbs ] && /usr/lib/mailman/cron/checkdbs
0 9 * * * list [ -x /usr/lib/mailman/cron/disabled ] && /usr/lib/mailman/cron/disabled
...
When I type list I get
No command 'lis... |
Lines in the system crontab (which is what I think you're looking at) have six fixed fields plus a command, in the form:
minute hour day-of-month month day-of-week user command
This is different from the per-user crontab which lacks the user field.
My guess is that list is the mailman user on that system. This user ... | What does list in crontab do? |
1,495,530,814,000 |
I have a folder "all_images/" with more than 1000 image files named as "Image1.tif", "Image2.tif" and so on..
I have a text file "extract_images_list.txt" which is a list of images that I want to extract from this folder.
Example:
Image23.tif
Image100.tif
Image248.tif
I want to move only those files mentioned in my... |
With the caveat that this solution can't possibly handle things like the Line Feed character being in a filename:
mkdir extract_images 2>/dev/null
while IFS= read -r file; do
mv "$file" extract_images
done < extract_images_list.txt
This goes through extract_images_list.txt line-by-line by reading them into the file... | subset files in a folder based on a list |
1,495,530,814,000 |
Input:
X Y
1 11
1 12
2 21
2 22
Desired Output:
11 12
21 22
I want to transpose the CSV file by the value of column 1. In this example, for X = 1, transpose (11, 12)^T to (11, 12); for X = 2, transpose (21, 22)^T to (21, 22)
|
perl
perl -lane '
push @{$rows{$F[0]}}, $F[1] if $. > 1
} END {
$, = " ";
print @{$rows{$_}} for (sort keys %rows);
' file
awk, assumes input is sorted on column 1:
awk '
NR == 1 {next}
NR == 2 {key = $1}
$1 != key {print ""; key = $1}
{printf "%s ", $2}
END {print ""}
' file
| Transpose CSV file by the value of a column |
1,495,530,814,000 |
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", %5, %8}
When I use xev there is only a certain bit of information I want. The natural response of using xev to get keycode info looks like this...
KeyPress event, serial 48, synthetic NO, window 0x1600001,
root 0xf6, subw 0x0, time 754405,... |
You seem to have correctly deduced what {a[NR+2]} NR in a { ... }} does;
/^KeyPress/ {a[NR+2]} creates an (empty valued) element in array a with index NR+2, when the start of line NR matches the string KeyPress
NR in a is therefore true for the line two lines below where /^KeyPress/ matched
In that respect, it coul... | Deciphering this AWK script |
1,495,530,814,000 |
By default when we copy and paste a file in same directory Ubuntu creates duplicate file and renames it to origname (copy).ext.
But I want to rename all those files such that the files like those names be renamed to origname_copy_02082016.ext means with todays date at the end just before extension.
How can I do that w... |
There are several rename(1)s out there, and they use different sets of options. Assuming your rename(1) supports Perl expressions, this should work:
rename -n "s/ \(copy\)/_copy_$(date +%d%m%Y)/" *
The -n option shows you what rename(1) would do without actually renaming anything. Remove -n when you're happy with t... | find files containing space and specific string in their filename and rename it |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.