date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,495,530,814,000 |
I am facing an issue in my project.We support an App which is hosted on a unix server.
Partners try to access the same from many regions. Now some users in an region say "R" are complaining about slowness and we have reason to believe that it might be due to a network issue which is at their end.
What are some comma... |
Inherent limitations
The issue could be variable (e.g. congested link to ISP or congestion within ISP). It could also be horrible ("firewall" or even "anti-virus" doing deep packet inspection); the tools below might not show any problem at all. They're worth having, but there is a limit to how much you can achieve j... | Network slowness [closed] |
1,495,530,814,000 |
One of my applications won't open so I'm trying the first thing to do on this website:
http://www.cnet.com/news/tutorial-what-to-do-when-a-mac-os-x-application-will-not-launch/
But I am getting an error for this command that I enter. Why?
sudo update_prebinding -root / -force
|
You are receiving that error because the program "update_prebinding" is not in your PATH, possibly because it is not installed on your system.
| Why am I receiving the error: "sudo: update_prebinding: command not found" on the command line? |
1,495,530,814,000 |
I would like to compare the first column of file1 with the second column of file2 and only if they match it should display any matching lines in file2 only as the output. The columns are separated by |.
file1:
syfar03040k16.audc1.oraclecloud.com |
syfar03040m02.audc1.oraclecloud.com |
syfar03040m04.audc1.oraclecloud.... |
awk '
NR == FNR {
file1[$1] = 1;
next;
}
$4 in file1 {
print $0;
}
' file1 file2
| Column comparison using awk [duplicate] |
1,495,530,814,000 |
I just started learning Linux commands. I was experimenting with the > command, that, as far as I understand, makes the command before it write it's output to the file after the sign. My perception however, seems to be different from the behavior of time > time.txt:
nagy@nagy-VirtualBox ~/Dokumentumok/random $ date
20... |
The time command does not do what you seem to think it does. In fact, since its purpose is to time the running of another command, running it without arguments (without a command to time) doesn't make much sense. (Apparently it still runs without complaint though!)
The specific effect you are seeing here is that time ... | "time > time.txt" refuses to work propely |
1,495,530,814,000 |
How do I do this in command line?
Below is code i saw imported to PhpmyAdmin but i don't use any interface...
CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_code` varchar(60) NOT NULL,
`product_name` varchar(60) NOT NULL,
`product_desc` tinytext NOT NULL,
`product_img_name` var... |
Assuming this is for MySQL (or MariaDB), and you have the above as the contents of a file named table_create.sql:
$ mysql --user=$USERID --password=$PASSWD --database=$DB < table_create.sql
You have to know what your MySQL user ID and password are, and know the database name. Substitute those strings as appropriate f... | how to create table with fields in command line Centos |
1,495,530,814,000 |
Assume a multitail call like the following:
multitail -s 2 -l "long-running-command" -l "short-running-command"
Now, I would like to have both windows remain open, even after they are finished. However, multitail will just close the "short-running-command"-window once it exits. Which makes it kinda useless for my use... |
There are a couple of approaches I can think of.
First, if you don't mind having multitail close when the longer running command finishes, you can pipe the shorter running command to it and display stdin:
short-running-command | multitail -s 2 -l "long-running-command" -j
Second, you can add a long delay after runnin... | Possible to prevent multitail from closing "finished" command windows? |
1,495,530,814,000 |
after reading the man pages I am unable to find an explanation of what this does (the tack e option)
usermod -L -e 1 username
-e 1
does this mean one day after the linux epoch, jan 1 1970? How would anyone know this since it's not documented anywhere?
|
You are right. It's value is in days.
From the usermod(8) man page:
-e, --expiredate EXPIRE_DATE
The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD.
But there is more information in the shadow(5) man page:
account expiration date
The date of expiration of the accoun... | usermod question about option e |
1,495,530,814,000 |
GNU bash, version 4.3.42(2)-release-(i686-pc-msys)
Usage: bash [GNU long option] [option] ...
bash [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noedi... |
Looking at the source code, --debug sets a debugging flag (in shell.c), but I can't find anywhere that flag is used. So it appears to not do anything.
--debugger activates support features for the bash debugger; the latter is probably what you're looking for.
| What the long option " --debug" suppose to do in bash? |
1,495,530,814,000 |
Some flac files apparently have a “cuesheet metadata block”. I know how to split flacs files with shnsplit when I have a separate cuesheet at hand (cf. “How do I split a flac with a cue?”), but how do I split a flac when the cuesheet is stored inside a metadata block of the flac file?
Command-line preferred.
|
By exporting the cue-sheet to a file first. For example, metaflac has an --export-cuesheet-to=FILE option.
From man metaflac:
Export CUESHEET block to a cuesheet file, suitable for use by CD
authoring software. Use '-' for stdout. Only one FLAC file may be
specified on the command line.
For example:
f='fil... | Splitting a flac from a cuesheet metadata block |
1,495,530,814,000 |
I need to run the same command every time I boot.
I'm running Linux Mint 17.2 Cinnamon.
I have added a startup application with the command under preferences "startup applications".
However the command does not run although it runs and works perfectly when I run it myself.
Details
The command is:
echo 'adminpassword' ... |
You do not need to run a program. You just need to configure your system to load the ndiswrapper module at startup.
For that you edit the file /etc/modules with the command:
sudo vi /etc/modules
And append to the end of it the line:
ndiswrapper
The file /etc/modules configures which loadable modules are automatically... | How do I enable a kernel module on startup? |
1,495,530,814,000 |
I'm planning to write a data cruncher command line tool, I'm considering Go, Rust and Javascript. But I'm afraid of jeopardising the project by using something not stable enough or painful to deploy.
Are there examples of widespread packages carried by many distributions written in Go?
And if I want to either write i... |
I'm not aware of widely-used tools written in any of those languages. Node.js is not any bigger a dependency than perl or python, though perhaps not as commonly installed. I actually just installed node 0.12 yesterday on a Windows system with no trouble.
My question is - why not C, python, perl, php, awk, bash scr... | Languages to use for console tools - Go, Rust, Javascript? [closed] |
1,442,690,062,000 |
I tried to remove Blender in the command line , in order to install it anew because of flawed selection in edit mode. So, this is what I typed and the error message I got, I do not understand the error-message.
sudo apt-get remove blender
[sudo] password for terazer:
E: Could not get lock /var/lib/dpkg/lock - open... |
As for understanding the message, the lock file is used to stop more than one package manager trying to modify the system at once. If this weren't here the system could easily become damaged beyond repair.
Therefore this normally means that another package manager is running at the same time. Do you have a graphical ... | How to remove Blender in the command line ? |
1,442,690,062,000 |
I have a directory looks like:
dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls
DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 DFT-00031 DFT-00034
DFT-00002 DFT-00005 DFT-00008 DFT-00011 DFT-00014 DFT-00017 DFT-00020 DFT-00023 DFT-00026 DFT-00029 DFT-00... |
This should do:
#!/bin/bash
# this is the crucial setting: replace a glob pattern that matches zero files
# with nothing (the default is to *not* replace the pattern at all)
shopt -s nullglob
destination=/some/directory
unique_filename() {
local root=${1%_*}_
local files=( "$destination/$root"* )
echo "... | extract subfolders outside and rename if necessary |
1,442,690,062,000 |
I would like to run multiple processes where each process is running another one, so it will create a long process branch.
I've tried:
$ bash -c '(bash -c "sleep 20"); sleep 20' &
$ pstree $(pgrep -fn bash)
which creates parent and one child process, but is there any trick or easier way of doing that it would generat... |
You can create a recursive script. eg in file /tmp/run
#!/bin/bash
depth=${1:-5}
f(){
let depth--
if [ $depth -gt 0 ]
then $0 $depth
else sleep 10
fi
}
f
then chmod +x /tmp/run and do /tmp/run 10.
| How to run bunch of hierarchical dummy shell processes (process of another process, etc.)? |
1,442,690,062,000 |
Given a large list of files, containing the following:
FILE1.doc
FILE1.pdf
FILE2.doc
FILE3.doc
FILE3.pdf
FILE4.doc
Is there a terminal command that would allow me to remove all files that do not have a duplicate name in the list? In this case...FILE2.doc and FILE4.doc?
|
Using bash, this will remove all files that don't have another file with the same name but different extension:
for f in *; do same=("${f%.*}".*); [ "${#same[@]}" -eq 1 ] && rm "$f"; done
This approach is safe for all file names, even those with white space in their names.
How it works
for f in *; do
This starts a l... | Delete all files that DON'T have duplicate names? |
1,442,690,062,000 |
I have 2 related Doubts about Bash.
(Q1) Consider tail -f SomeFile | wc, a fictitious command-line, where tail is used to simulate a command (C1) which runs for a long time, with some output from time to time, and wc is used to simulate a command (C2) which processes that output when C1 finishes. After waiting for a l... |
In bash you can run:
cmd1 | cmd2 | (trap '' INT; cmd3)
And a Control-C will only kill cmd1 and cmd2, but not cmd3.
Example:
$ while sleep .1; do echo -n 1; done | (trap '' INT; tr 1 2)
^C222222222
$ while sleep .1; do echo -n 1; done | tr 1 2
^C
This takes advantage of the fact that a signal disposition of "ignore" ... | How to kill only current process and continue with shell pipe-line? |
1,442,690,062,000 |
I was reading this link from MySQL:
https://dev.mysql.com/doc/refman/5.6/en/mysql-cluster-install-linux-binary.html
shell> cp support-files/mysql.server /etc/rc.d/init.d/
shell> chmod +x /etc/rc.d/init.d/mysql.server
shell> chkconfig --add mysql.server
In the mysql.server file the content says:
PATH=$PATH:/usr/local/... |
First part of this question refers to some how to, which is NOT making program available from everywhere -- it is making the program available from that particular init script, which is the correct solution for such task.
Second part lists the correct solution to make it available from everywhere. If you see manual pa... | How must (Not how can) a program be available from everywhere in CentOS/Fedora |
1,442,690,062,000 |
I want to write a Script that picks a random English word from /usr/share/dict/words, translates it into German, display both of them for a certain amount of time and repeat the process. I only know the beginning part and do not know how to use a word to word translation in the shell:
watch -n5 sh -c 'cat /usr/share/d... |
Download Translate Shell
cd
wget https://github.com/soimort/google-translate-cli/archive/master.tar.gz
tar -xvf master.tar.gz
cd google-translate-cli-master/
Install
use make
sudo make install
OR
use checkinstall
sudo apt-get install checkinstall
sudo checkinstall
If you see this: 3 - Version: [ master ]then
Pre... | How can I translate in the CLI an English word into a German one? |
1,442,690,062,000 |
sudo apt-get install anjuta
Error I get while installing the IDE. What is this error about? However, I am able to successfully install the IDE
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Unknown media type in type 'uri/mms'
Unknown media type in type 'uri/mmst'
Unknown media type in... |
It is caused by a KDE library adding custom MIME types.
Fix it with:
sudo mv /usr/share/mime/packages/kde.xml /usr/share/mime/packages/kde.xml.bak
sudo update-mime-database /usr/share/mime
| Error I get when I try install IDE Anjuta |
1,442,690,062,000 |
Assume, someone searches for files that match some criteria using the find command and pipes the result into the rm command.
find / -type f -name "*.jpg" | xargs rm
First, I am not sure if the command above will get an error if the number of found files is very big, because I guess there is a limit to the number of ... |
The limitation you mentioned is generally about the exec buffer used, not specific to individual commands. The purpose of xargs is exactly to address that problem; xargs will take as many arguments as possible to feed the command. This will get you the least command calls and thus good performance. Reducing the amount... | Makes it a difference whether I use a different -n flag value for xargs in combination with find command ? |
1,442,690,062,000 |
I know the > and >> operators, > puts something into a file by deleting the old content, >> appends something onto the end of the file's content.
When I only use
cat > foo
I am able to write several lines into foo interactively until I hit ctrl+z, than it ends.
Now, if I add the append operator in the reverse ord... |
$PS2
Each time the user enters a \newline prior to completing a command line in an interactive shell, the value of this variable shall be subjected to parameter expansion and written to standard error. The default value is >.
You see the > because that is the default value for $PS2 - which is the prompt string th... | What is the logic behind the expression cat > foo << "wordofchoice" [duplicate] |
1,442,690,062,000 |
After editing context menu entries (by editing files in /usr/share/contractor) I have to restart the file manager to see the changes.
How to restart Pantheon Files with a command so that I don't have to log out and in?
|
Run the command pkill pantheon-files in the terminal The pkill command sends a signal to terminate the process with name pantheon-files; a process is a running instance of a program. Reopen the file manager by clicking on the icon on the dock or from the application menu. By clicking on the icon, a new process is star... | Command to to restart Pantheon files manager (elemenaryOS)? |
1,442,690,062,000 |
I have create a gerber file and it has lines inside which look like this:
X90095Y15350
X100095Y15350
X110095Y15350
X120095Y15350
X120095Y25350
X110095Y25350
X100095Y25350
X90095Y25350
X80095Y25350
X160095Y25350
These are coordinates of the drill path - mind the X and Y. Number after the X and Y varies - it is someti... |
Try this:
sed 's/\(^X[[:digit:]]\{4\}\)[[:digit:]]*\(Y[[:digit:]]\{4\}\)[[:digit:]]*/\1\2/'
If line starts with X (^X) then all digits which are not inside parenthesis \(\) are deleted.
| Coordinates X237595Y81600 to X2375Y8160 |
1,442,690,062,000 |
I'm using diff -rq to compare directories on a Mac OS X 10.6 server. In folder1, we have 'filename'. In folder2, we have'filename.archive' because folder2 is created by a file sync app that also archives the files it syncs.
We've just pulled folder1 from a backup and I want to see what, in folder2, is more recent and... |
You cannot do this with "just" diff as the filenames do not match in both directories and diff doesn't have anything build in to do the mapping.
What you can do is change to the "new" directory and do:
for i in *; do diff "$i" /path/to/other/dir/"$i"; done
or, change to the restored backup dir and do:
for i in *.arc... | Diff: slightly different filenames, same file |
1,442,690,062,000 |
I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this.
I want to make this as an installable API, I mean to install through apt-get/ yum install. In terms of yum I have to create a repository and place the module in a FTP location. Bu... |
You should approach this as a two step process.
First make your api installable using pip by creating a setup.py file for the project and use setuptools. There is quite a lot to go through and I recommend you follow some of the examples out there to go through the steps before you start tweaking to get your own proje... | Make python module as an installable API |
1,442,690,062,000 |
After performing a series of actions in Linux's terminal, I am supposed to perform a "listing" of them.
I couldn't find it online. All I can guess is that I am supposed to make the terminal print out a list of recently performed actions.
What command is used for doing something like this?
|
An “action in Linux's terminal” is presumably a command that you typed at a shell prompt.
Typical shells record a history of past commands. In bash, the commands fc and history both display the history of recent commands; see the manual for available options. You can also navigate among past commands by pressing Up an... | What is (and how to perform) action listing? |
1,442,690,062,000 |
Suppose I have a file. This file is stored in some complex location (within a hundred subfolders), but I nevertheless use it a lot. Is there some way to assign this file a set of keywords (i.e., "my favorite file") and then to input those keywords later on in some natural language processor (eiher a command line int... |
Yes it does:
Create a link to it as explained by @emory.
Make it an environmental variable. Add this line to your shell's initialization file (~/.bashrc if you're using bash):
myfile="/absurdly/long/path/that/you/would/rather/not/type/every/time"
Then, from the commandline, you can use $myfile as though it were the a... | Assigning files key words to easily find them later |
1,442,690,062,000 |
I executed the minimal building directions of xcape:
$ sudo apt-get install git gcc make pkg-config libx11-dev libxtst-dev libxi-dev
$ mkdir xcape
$ cd xcape
$ git clone https://github.com/alols/xcape.git .
$ make
But when I press xcape it says xcape: command not found. It errors even when I'm in the xcape folder wi... |
Have you tried ./xcape ? You have to execute it this way, because the location is probably not defined in the $PATH variable.
| Installing Xcape (question involving the "make" command) |
1,442,690,062,000 |
I have been using, studying and developing for Linux for quite a few years now, and over time, I have successfully convinced a few people to join the cause, and make the switch to Linux.
However, when these people went discovering this brand new world, every one of them eventually came to me, asking what the command w... |
The POSIX shell spec refers to simple commands, compound commands, command position, and the command command.
The first two reference how/when a shell command is parsed and executed. For instance:
#one compound command
{ simple command; simple command && simple command; }
The compound command is how much the shell m... | What is the concept hidden behind the term "command"? |
1,442,690,062,000 |
It sounds really simple, but many times I was stuck at the beginning of learning a new command. The tutorial writer think it's natural to start, but it's not.
This is the tutorial I've been reading:
http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800
After reading that, I started something l... |
crontab -e
it will open a configuration file in editor and you then add your line to the end:
* * * * * /usr/bin/sh t.sh
| How to start a cron task? |
1,442,690,062,000 |
In case there's a better solution to the problem, my goal is to be able to quickly analyze ALL recent apache activity in /usr/local/apache/domlogs. The usefulness of this is when the server load is going through the roof I want to quickly see which website(s) are getting hammered (and what URLs) without having to indi... |
You can use -exec option:
find -regex '.*.(com\|org\|net\|biz\|info)' -mmin -1 \
-exec tail -n 1000 "{}" >> logs.txt +
Now all last 1000 lines of each files in domlogs is written to file logs.txt, separated by filename.
-exec command {} + tells find to run command with files found, the command line is built by ap... | For a given directory, how do I concatenate the tail end of recently modified files to a new file? |
1,442,690,062,000 |
Is it possible to start an xfreerdp session into Microsoft windows from a command-line only install of Linux?
The command I use from a full blown Linux install is this:
$ sudo xfreerdp /v:farm.company.com /d:company.com \
/u:oshiro /p:oshiro_password /g:rds.company.com
This command works fine. However, when I run... |
If you're just logged into a system that doesn't have a X desktop running then no you won't be able to make use of xfreerdp or any such application that requires the use of a GUI.
Remember that the X desktop is driving the videocard & monitor locally and is providing a basis (the X protocol) on which other graphical ... | Logging into an RDS session from the command-line |
1,442,690,062,000 |
I use to establish a connection to my VPN PPTP server by typing:
pon MyVPN persist
I want to know the reconnection timing details, but I have not found documentation enough about it. Specifically:
- If there is a disconnection, does the PPTP client attempts to reconnect immediately?
- What is the frequency ... |
As far as i can see the reconnection is immediate (although it sometimes takes some time for it to detect that connection is broken).
I believe there's no lag between retries but you can set up it by using holdoff n where n is the number of seconds between the disconnection and next try to reconnect.
As for a number ... | What is the reconnection policy of "persist" switch on "pon" command from pptp-linux package? |
1,387,291,572,000 |
When I cd to a/b/c, sometimes I want to see what are the children dirs of c. Normally, I would do it like this
cd a/b/c
ls
child1 child2
cd child1
Is there any way to investigate the children without stopping to do the ls?
|
Do cd a/b/c and hit Tab several times. It works with Bash if you enable the completion.
| Is there any way to see the options for the next directory on a cd command? |
1,387,291,572,000 |
I started recently to learn using Linux. I want to write a script in bash shell to run a serial job on a cluster. I have been searching for hints and instructions on how to write such a script. I managed to write the following:
#!/bin/bash
#PBS -l nodes=1:ppn=8
#PBS -l walltime=1:00:00
#PBS -e test.err
#PBS -o test.lo... |
You don't specifically say which clustering software you're using, but based on the fact you're asking about qsub, I know that both GridEngine (and derivatives) along with PBS use that particular command, so let's start with those.
I'm most familiar with GridEngine (and derivatives) so to submit a command using that p... | Script for running sequential job |
1,387,291,572,000 |
I want to create dump file of sqlite database from java but I can't run the below command from linux. I got the help of windows and I tried with linux but it appears one terminal nothing more than that. So can anyone help me how to write this command in linux?
Process p = Runtime.getRuntime().exec("cmd /c start /b ... |
I found the solution:
Process p = rt.exec(new String[]{"/bin/sh", "-c", "sqlite3 /home/ubuntu/testingdb.sqlite .dump > /home/ubuntu/success11.sql"});
It gives full dump file of sqlite database..
| how to run .dump command in linux? [closed] |
1,387,291,572,000 |
I'm trying to get an itemized list of files transferred by rsync. Using the -i and --out-format options, I'm instead ending up with output that looks like this:
3HMP1MO_001.tif
974.68K 100% 9.58MB/s 0:00:00 (xfer#1, to-check=8/10)
3HMP1MO_002.tif
974.68K 100% 2.27MB/s 0:00:00 (xfer#2, to-check=7/... |
surely I'm just doing something wrong?
I'm guessing you've spotted this yourself by now (from man rsync):
--progress show progress during transfer
I wonder how it will do that? ;P
| Get a clean list of files transferred from rsync |
1,387,291,572,000 |
I am trying to understand the correct use of »atomic grouping« a.k.a. »independent subexpressions« a.k.a. »non-backtracking subpattern« [this are the terms I found for the same thing, which doesn't make it less complicate]
egrep '123(?>fruit|juiceomatic)machine' means: look for
123fruitjuiceomaticmachine
BUT stop try... |
This is not an extended regular expression (ERE). egrep will interpret this as 123 followed by either >fruit or juiceomatic (the ? is ignored) followed by machine. This means it will match on:
123>fruitmachine
123>juiceomaticmachine
but not:
123fruitjuiceomaticmachine
The (?>...) notation is from PCRE and means non-... | (e)grep and atomic grouping [comprehension question] |
1,387,291,572,000 |
Why don't the commands have a & between the setting of DISPLAY and running unity or compiz.
I understand that both work (re-starting unity or compiz), but fail to see why are they the way they are.
|
Because the value for DISPLAY is set for that one execution of one command, only.
| Syntax of DISPLAY=:0 unity --replace or DISPLAY=:0 compiz --replace |
1,387,291,572,000 |
I have installed the packages tinymce and tinymce2. It's an HTML Editor.
sudo apt-get install tinymce tinymce2
but when I launch the command tinymce the system tells me there's no such command. Same for tinymce2. I have noticed that they don't seem to be in /usr/bin/
I have tried man tinymce and man tinymce2 and the ... |
tinymce is a javascript library for HTML so you need to create HTML and put it onto web browser.
The javascripts are located in /usr/share/tinymce/www, you can create link in document root of your web server.
| How to find the command line for tinymce |
1,387,291,572,000 |
I'm using yamlfix with ale in vim.
I followed these steps because I wanted to remove the automatic "---" adding on top of the file every time I save my work (and some others default configurations).
For some reason, the file is correctly fixed, but my configuration is skipped..
So I decided to try with CLI in order to... |
When running yamlfix directly from the command line (or via a shell spawned from Vim, and not via e.g. maison), your TOML configuration file should contain no section headers:
$ cat myconfig.toml
explicit_start = false
You may then run yamlfix from the command line like so:
$ cat test.yml
---
test: some test data
$ ... | yamlfix not using configuration + (neo)vim usage |
1,387,291,572,000 |
The key combination Alt + 6 for copy in nano does not work in tilix
Does anyone know how to fix this? I had a look through all the key commands, but did not find any entry for Alt + 6 being already in use.
|
In Tilix version: 1.9.6 you can manually change and set key commands. Disable Alt + 6 which is set to switch to terminal Nr.6. by default.
| The key combination Alt + 6 for copy in nano does not work in GNOME terminal emulator Tilix |
1,697,393,844,000 |
After a fresh Ubuntu Server install, the console (no GUI) output is not aligned to the left side of my 4k screen. Instead, each line starts at a third of the screen width away from the right side, and then overflows to the left side of the screen.
This doesn't seem to be a problem with lower-resolution screens (tested... |
Your card might not be able to drive that monitor. 4K seems to be a common barrier, even for some 3-y.o. cards.
| Console output not aligned on 4k screen |
1,697,393,844,000 |
I am trying to create a bash function vim_run which operates as follows:
user pipes command output into vim_run
user can edit output
user exits vim and the contents of that buffer are now executed via source file
This flow is useful for editing a list of files one wants to remove. I have it currently implemented as
... |
This fixes it for me:
function vrun() {
local tmpfile=$(mktemp)
cat > "$tmpfile"
vim "$tmpfile" < /dev/tty
source "$tmpfile"
rm "$tmpfile"
}
We must just redirect the controlling TTY of the session to be Vim's stdin.
| Calling vim in subprocess after running cat |
1,697,393,844,000 |
I have a cli output as below,
GROUP DEFINITIONS SERVICE DIMENSION
RESULTSBYTIME False
KEYS AWS CloudShell
BLENDEDCOST 0.0000026589 USD
KEYS AWS CloudTrail
BLENDEDCOST 0.000001 USD
KEYS AWS Config
BLENDEDCOST 46.921 USD
KEYS AWS Glue
BLENDEDCOST 355.70735552 USD
KEYS AWS Key Management Serv... |
With GNU sed:
sed -z 's/\nBLENDEDCOST//g'
or perl:
perl -0777pe 's/\nBLENDEDCOST//g'
To match your output, you will need to add "Blended cost" to the header and remove second line, and remove the USD, e.g. pipe output to:
sed '1s/$/\BLENDEDCOST/; 2d; s/[[:blank:]]\+USD$//'
In total:
some_command | perl -0777pe 's/... | Is there option to convert outputs of row in to new column in linux and delete duplicate entry in row |
1,697,393,844,000 |
I have the following dir structure:
relative_path/
app1/
data
config
trash
other_app/
inputs
outputs
garbage
anything_else/
... |
Get the directories of the target depth with GNU find or a shell loop, use
-s (same as -d0) to display a total for each argument. This would
output relative_path/anything_else/v1 but show the total for this dir and its subdirectories.
If you also want to exclude the sizes of subdirectories, add another -S.
find relati... | How to find the disk usage ONLY of 2nd level dirs? |
1,697,393,844,000 |
ascii command in Linux is fast and great. It allows us to search for a character or for a code point and returns all relevant results for a given search. Is there something similar for ASCII extended (e.g.: ISO-8859-1) and/or for Unicode characters?
|
The unicode tool provides similar functionality to ascii:
$ unicode -d ..255
.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
000.
001.
002. ! " # $ % & ' ( ) * + , - . /
0... | Command similar to ascii for ascii extended and/or for unicode? |
1,697,393,844,000 |
Id like to create a video C with audio from video A but video from video B.
Video A and video B have nearly the same length in seconds.
Since the videos are a couple GBs, I guess it would be slower if I first extract audio from video A, then later merge that audio into video B (I mean, one step should be faster than t... |
I've been using this for a while:
ffmpeg -y \
-i "$videofile" \
-i "$audiofile" \
-c:v copy -c:a aac \
-map 0:v:0 -map 1:a:0 \
"$outfile"
I haven't tried it with files that are only "nearly" the same length, though.
| how to insert audio from video A into video B (no audio)? |
1,668,467,325,000 |
I'm trying to build opendingux from github repo/source. https://github.com/OpenDingux/buildroot
OpenDingux is an embedded Linux distribution focused on (retro) gaming.
I cloned the repo and then ran the commands below.
cd ./buildroot;
export CONFIG='gcw0'; bash ./rebuild.sh;
The output from the above command was pret... |
/bin/bash: line 2: 186552 Killed build/genautomata ../../gcc/common.md ../../gcc/config/mips/mips.md insn-conditions.md > tmp-automata.c
make[3]: *** [Makefile:2459: s-automata] Error 137
means that bash exited with exit code 137 (128 + 9), which means the process was killed with signal 9, SIGKILL. T... | error trying to build/make from source |
1,668,467,325,000 |
lets say I go to this file on linux CentOS to setup some startup commands
sudo vi /etc/rc.local
in this case lets say I want to startup uwsgi
so normally in the command line I might type something like this:
[linuxuser@localhost ~]$ systemctl start uwsgi
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units =... |
It wants to authenticate because you're not root. So starting from rc.local will work as that runs as root. But this is not the way to go - uwsgi is a service so can just be set to start at bootup anyway:
sudo systemctl enable uwsgi.service
| Running a few commands (that then ask questions) on startup |
1,668,467,325,000 |
I would appreciate having your advice on the below.
Having a folder name "ABC" with thousands of .xml files inside. The core structure of XMLs is the same:
<product abcd…>
<category>
...
</category>
</product>
Some xml files can be considered as valid as these contains a required <category> tag) some of these a... |
Assuming that all XML files are well-formed: Using xmlstarlet, the following prints the input filename of any file that does not have a category node as a direct child node under product:
xmlstarlet sel -t --if '/product/category' --else -f -nl ABC/*.xml
If you just want to detect files without any category nodes any... | search of .xml files without certain tag through mac os terminal |
1,668,467,325,000 |
I have a script that has the following steps:
1 mirror a remote server with lftp
open ftps://'[name]':'[pwd]'@[remote_host]
set ssl:check-hostname no
mirror --delete-first --only-newer /ExchangeSets
/home/sandbox_autopilot/Exchangesets
exit
2 next I sort the files based on the start of the filename using t... |
The cp command can preserve the attributes, including the timestamps.
The easiest way the archive: cp -a you preserve all attributes.
From manual:
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional at‐
tributes: context, link... | find command, only execute when file is newer |
1,668,467,325,000 |
The description for the wall command states that it sends a message to all logged in users. However, the man page describes a flag, -g --group, which allows the sender to limit messages to a specified group:
-g, --group group Limit printing message to members of group defined as a group argument. The argument can be... |
Looked at the group membership checking code. Had a round of gdb --args wall -g root foobarbaz,
break is_gr_member
run
{wait for breakpoint to be hit}
finish
print utmpptr->ut_user # this prints my own user name
step # this shows we're actually taking the branch as if I was a member of group root
So, yeah, that's a ... | How to limit messages from the wall command to a specific group? |
1,668,467,325,000 |
I call a python script with some command line arguments like:
python3 script.py --run 1 --filepath "this/file/dir"
I now try to parse the arguments from a config file with:
grep -v '^#' ${THIS_FILE_DIR}/model.conf | sed 's/=/ /' | xargs -I% echo "--%"
This yields my desired string:
--run 1
--filepath this/file/dir
... |
you have multiple choices, since you already use sed, I would suggest
python3 script.py $(sed -e '/^#/d' -e 's/=/ /' -e 's/^/--/' ${THIS_FILE_DIR}/model.conf )
where
use -e to specify multiple sed commands
'/^#/d' delete lines starting with #
's/^/--/' replace start of line by --
| Dynamically generate arguments for python script input |
1,668,467,325,000 |
I want to make it so that instead of a single hostname specified on the command line, it reads in a list of multiple target IP addresses from a file.
#!/bin/bash -
# bannergrab.sh
function isportopen ()
{
(( $# < 2 )) && return 1 # <1>
local host port
host=$1
port=$2
echo ... |
You seem to want to have "$1" represent a file containing a list of targets, instead of being just 1 target.
So you will need to englob the main part in a loop
ATHOSTFILE="$1"
SCRATCH="$2"
for ATHOST in $( cat "$ATHOSTFILE" ); do
... # (the rest of the actions here)
done
Note that the $( cat "$ATHOSTFILE ) part wi... | Instead of a single hostname specified on the command line, it reads in a list of multiple target IP addresses from a file |
1,668,467,325,000 |
How can I get the position of an argument by using its value?
For example:
myScript.sh hello world
echo "$1"
hello
How can I get the position of 'hello', which is 1 in this case?
|
While it wouldn't surprise me if there were quicker, easier ways, something like this should work:
#!/bin/bash
pos=0
found=no
for arg ; do
let pos++
if [[ "$arg" == "hello" ]] ; then
found=yes
break
fi
done
if [[ "$found" == "yes" ]] ; then
echo "Found hello at position $pos"
else
e... | Get argument position given its value in a bash script |
1,668,467,325,000 |
I have this data
photo for Kurtis Hardy" data-
photo for Paul Hoven" data-sr
I would like filter this to only get the name in the middle.
I used this command to get those line
cat File| grep -E -o 'photo for.{0,20}'
|
No need for cat here. Leave the cat alone.
I'm assuming every name starts right after the "photo for " and ends with the first " as in your example. Let me know if that is not the case. Otherwise we will need to think more about what counts as a "name".
grep -E 'photo for [^"]{0,20}"' File | sed 's/photo for \([^"]\{0... | String processing: remove a prefix and capture all characters before a double-quote |
1,642,514,714,000 |
I can't use environment variables with chmod command. Is there any workaround to run this?
The way I'm trying to run in a sh file
export PEM_FILE="~/.ssh/xxx.pem"
chmod 400 $PEM_FILE
## Output
chmod: ~/.ssh/xxx.pem: No such file or directory
However, it work perfectly fine without the variable like this: chmod 400 ... |
Unfortunately, special characters like ~ do not work in strings. Instead, use a variable like $HOME to point to the home directory, or remove the quotes. (not recommended because it breaks compatibility with some shells)
So you would do something like:
export PEM_FILE="$HOME/.ssh/xxx.pem"
or export PEM_FILE=~/.ssh/xxx... | Why can't I use environment variable with chmod command? [duplicate] |
1,642,514,714,000 |
I'm trying to set up a simple script that would clean up my working folder.
The working folder is structured like that:
Project 1
Project 1 [edited]
Project 2
Project 2 [edited]
Project 3
Project 3 [edited]
...
All project folders contain only files. The objective is to get rid of all folders within working folder th... |
With GNU find, something like
find . -maxdepth 1 -mindepth 1 ! -name "*edit*"
should match the files in the current directory that don't have "edit" in their names, and print the names. Of course you could add e.g. -type d -iname "*project*" to match only directories with "project" in the name. If the output looks c... | Delete all folders in specified path that do not have word "edit" in them? |
1,642,514,714,000 |
I execute a set of handy commands I need to do often on a standard type of file using the -c (or equivalently, the +) option from command line using vim. However, after an update to the remote system's OS, commands beyond the first one are interpreted as different file names and results in the first command being exec... |
Answer here: https://vi.stackexchange.com/a/31833/37021
The issue was a bug in a wrapper function on the remote system that was passing the command line arguments incorrectly to the vim executable.
The fix was to alias vim to run the executable directly and file a bug report to the sys admins about the wrapper functio... | Cannot string together multiple "-c" options using vim from the terminal |
1,642,514,714,000 |
When I tried to run this command line
cp -a /home/root1/.Xauthority .Xauthority
`
this error appear, What the reason is?
cp: cannot stat '/home/root1/.Xauthority': No such file or directory
please, I need help for this problem.
|
I got this to work for Brave on my Linux Mint 20.1 system:
xhost SI:localuser:root # give root access to the display.
sudo su - # switch to root user's shell
env DISPLAY=:0.0 brave-browser --no-sandbox
I did not need to copy the .Xauthority file.
| When I need to make Firefox and brave run as root and transfare Xauthority this error appear |
1,619,357,947,000 |
new to stackoverflow and linux usage, have a NAS setup on HC4 currently trying to set up a steam cache, after installing docker I was trying to install network-manager which lead me down a rabbit hole because it returned errors such as :
W: Failed to fetch http://deb.debian.org/debian/dists/stable/InRelease Could not... |
Alright been messing around with it and the issue seems to have been that the OMV config for eth0 and the network manager config were set differently, so after manually setting both to the same settings it was able to resolve hosts.
| Debian HC4 NAS can't resolve any host |
1,619,357,947,000 |
Installed qemu kvm, created Windows10 vm and I can start and open it from the GUI. Exited (quit, not close) KVM GUI.
# virsh list --all
Id Name State
------------------------
- win10 shut off
Then I ran:
# virsh start win10
Domain win10 started
Again listed status:
virsh list --all
Id Name ... |
Ok, my bad.
Forgot about remote-viewer.
I opened it with
remote-viewer spice://127.0.0.1:5900
| How to open (not only start) virtual machine from CLI |
1,619,357,947,000 |
I have several hundred directories currently in this form :
Band Name - Album Name (year)
I would like to rename everything (with a mass treatment) in
Band Name (Year) Album Name
Almost all of my directories have this naming rule (with a few exceptions ready)
Not being an expert in bash scripting, I'm here to ask for ... |
With zsh:
autoload zmv
zmv -n '(*) - (*) (\(<->\))(#q/)' '$1 $3 $2'
Remove -n (dry-run) when happy.
| Change the position of a word in directory name |
1,619,357,947,000 |
redshift is a package that enables blue light filter, so people can avoid eye strain.
This software is pretty good, but it lacks controls to adjust the filter color temperature, incrementally: no sliders, buttons or commands.
When I say "incrementally", what I mean is that I need a command to set color temperature acc... |
I figured it out and made a simple package called tempcolor.
Now, I'm able to even create keyboard shortcuts to change color temperature incrementally.
install
place the contents of the repo wherever you want to;
make tempcolor executable: chmod +x ./tempcolor;
feel free to create a symbolic link for tempcolor.
be i... | How to create a command to incrementally increase redshift's color temperature? |
1,619,357,947,000 |
I have logs file that contain date and username something like below
Nov 05 14:36:03.752146 server.com [2020-11-05T14:36:03.752Z] [C 7f7e597fa700] R=6ssssdsdsd 91,CN= user1 drop: UP 10.11.100.100 TO 10.20.20.139 ICMP 8:0:1:23249 SIZE 60
how can I grep date which Nov 05 and user1 in the commandline
Thanks
|
May be this will help you to get the details : Run the below command on website : https://rextester.com/l/bash_online_compiler
#!/bin/bash
str='Nov 05 14:36:03.752146 server.com [2020-11-05T14:36:03.752Z] [C 7f7e597fa700] R=6ssssdsdsd 91,CN= user1 drop: UP 10.11.100.100 TO 10.20.20.139 ICMP 8:0:1:23249 SIZE 60'
dt=`... | grep multiple words that have space |
1,619,357,947,000 |
How may I change my doas prompt? For example, to change sudo prompt you just run
export SUDO_PROMPT="Prompt: "
Is there an equivalent for doas?
|
The OpenBSD doas(1) utility does not allow you to change its prompt in the same way that sudo does. This is by design, to keep it as simple as possible (which is why it was written in the first place).
| Changing "doas" prompt |
1,619,357,947,000 |
I am creating a custom shell using C language and I am successful with parsing, fork and exec, pipes, redirection etc. I noticed one particular type of command which seems to be throwing my shell off.
In bash shell , the following command works.
bash> echo "abc" >> tempFile
bash> sed s/a/b/g tempFile
bash> sed 's/a... |
Thank you to @iFreilicht and @Andy Dalton. It was very silly of me. The Bash shell consumes the quotes and depending on if the argument was enclosed with ' or " , the shell will interpolate the arguments. This stackoverflow thread offers a more detailed explanation.
| Understanding command line arguments in custom shell and the effect of using quote |
1,619,357,947,000 |
I installed Debian 10 with Xfce Desktop Environment. And I installed a minimum set of browsers like this:
$ sudo apt -y install firefox chromium
For development purposes I also want to install opera, yandex-browser and google-chrome. Previously I used a browser for this.
How can I do it from console?
|
Create a script to install browsers, which consists of two parts: first add the browser repositories, and then install browsers themselfs from these repositories. browsers.deb.sh:
wget -qO - https://deb.opera.com/archive.key | sudo apt-key add
sudo tee /etc/apt/sources.list.d/opera-stable.list <<DEBREPO
# This file m... | How to install a browser from the command line? |
1,619,357,947,000 |
Basically I have an application server and would like to allow the Owners/Admins of the Application to be able to run any sudo command on the directories related to the application. For example, if the application directory is /opt/my-application, the user would not be required to run "sudo vim /opt/my-application/som... |
In your sudoers file:
user ALL=(root) NOPASSWD: /usr/bin/vim /opt/my-application/some-file
This line only will be allow the specific command to run.
But you cannot change the permissions to directory (chmod or setfacl)? Or change default umask value?
| Is it possible to allow passwordless sudo for a specific directory |
1,599,246,125,000 |
Taking a random word as input from the user, can anyone suggest a logic in shell scripting to check if any permutation of that word is actually an executable command or not?
|
Try pipelining with compgen command
| Check if a user given random word is an executable linux command or not? |
1,599,246,125,000 |
My computer turned itself off to protect itself from a power-surge. This has happened before many times, with nothing weird happening the next time I turned on the computer. I would press the power button, wait a minute, enter my password, and then be right back at my Desktop. This time however, something different ha... |
Your disk probably has been at least partially corrupted.
There are a variety of good answers on this post. I would post this as a comment, but I am 4 points away from being able to comment:
https://askubuntu.com/questions/137655/boot-drops-to-a-initramfs-prompts-busybox
| Stop BusyBox Command Line for Loading on Start Up |
1,599,246,125,000 |
I'm trying to find all lines of a file not being after a specific pattern.
For some time I had an issue with my history using GNU bash (version 4 and 5) where commands appeared in duplicates. I assumed this was due to the fact that in my .bashrc I had the following line:
PROMPT_COMMAND="history -a; history -n; $PROMP... |
As far as I understand grep -v "^#" -A 1 means to print the lines that don't start with a hash sign, and one line after each. But don't you want the opposite, print the lines that do start with a hash sign, and one line after?
Given a test file:
#123
echo this
echo this
#456
echo that
echo that
echo that
#789
echo thi... | grep for lines not after a pattern |
1,599,246,125,000 |
I would like to write a script which add/create the file (like touch does). But, something own. First lines will be variables. Where:
echo -n "Choose your folder to save the file: "
read dir
echo -n "What is the name of your file: "
read name
etc.
But in this case I should type a full path, but I want to use TAB butt... |
You want tab-completion to work when entering input to Bash's read? Then read -e is what you're looking for (manual):
Options:
-e use Readline to obtain the line in an interactive shell
e.g.
/tmp/foo$ touch abcdef abcghi
/tmp/foo$ read -e -p 'enter a filename: '
enter a filename: ab[tab]
abcdef abcghi
Th... | Make 'complete' built-in command works for 'read' command |
1,599,246,125,000 |
I have a large text file with multiple occurrences of a tag containing a URL:
[tag]https://example.com/222389/link/11835457224168404[/tag]
I need to reformat the tags as follows:
[new-tag]11835457224168404[/new-tag]
(capture just the part of the url after 'link' (the 'id') and modify the tag to 'new-tag':
There can... |
Strategy
Whilst it is possible to write regular expressions which don't match multi-character strings, they get complicated. We will use a trick to convert [tag] and [/tag] into single characters and then use negated character classes. In this script I will use control-a and control-b. It is critical that these charac... | Sed change a tag and keep part of the contents |
1,599,246,125,000 |
I'm working with Apache Geode nodes, all of the work is being done via the Linux CLI. Normally when I edit the config files (with VIM) the text looks like this:
"nodes": {"long_UUID_here": {"node_uuid": "another_long_string_here", pair_uuid:" null,
"is_admin_node": false, "ip_address": "ip-or-fqnd.domain.com", "prefe... |
A colleague of mine from DevOps showed me how to do this with sed + regEx + json.tool:
`echo sed -nre "/clusterMembership/ s/^[^']+'([^']+)','([^']+)'.*/\2/p" /path/to/file/here/node.file.config | python -m json.tool
| How can I list out bracketed text in Linux CLI in a readable format? Apache Geode node names & info |
1,599,246,125,000 |
I want to repetitively untar a file which I often download in new versions; for example:
cd download_directory
myFile-1.99.tar.gz # Version 2.x might be released next day or next week or next month;
I have tried a similar command with shellglob/wildcard which failed:
cd download_directory
tar -xzv myFile-*.tar.gz
I ... |
cd download_directory
tar -xzf "$(find . -name 'myFile-*.tar.gz' | tail -n 1)"
| How to untar in a version agnostic way? |
1,599,246,125,000 |
I want to have some extra binaries / command available when I'm on terminal, triggered by the CWD.
Let following be the directory structure as one example
├── P1
| ├── mybin
| │ └── cmd1
| ├── S1
| │ └── mybin
| │ └── cmd2
| ├── S2
└── P2
└── S3
Then in this directory structure
cmd1 and cmd... |
I understand that you're not happy with just
PATH="./mybin:../mybin:../../mybin:../../../mybin:$PATH"
until some limit like 8 or so sub-directories.
Instead of polluting and breaking your regular command lookup, I suggest you use a short wrapper, such that the recursive lookup will only be done for the commands prefi... | Recursive lookup of a binary in current directory's parents through hierarchical $PATH |
1,599,246,125,000 |
I was trying to find all the users in my Gnu/Linux system that have access to one particular folder.
I tried
$ ls -ld */
dr-xr-xr-x. 2 root root 28672 Mar 20 21:33 bin/
dr-xr-xr-x. 4 root root 4096 Mar 16 16:02 boot/
I tried ls -ldd */ , but it list only 1 row for one folder with the user name with which... |
Quick and Dirty and only tested on a Mac (which doesn't use getent). I replaced getent with the mac command to test "dscl . -ls /Users"
chkgrp=$1
for userid in $(getent passwd); do
echo "$(id -Gn $userid)" | grep -wq $chkgrp
[[ $? -eq 0 ]] && echo "$userid is in the $chkgrp group"
done
| Gnu/Linux command to list all users who has access to one folder |
1,599,246,125,000 |
I was reading about the echo command in UNIX and i found the -e option which is used to enable the interpretation of backslash escapes, the thing is one of these backslash escape sequences was the \ \ ,but when i used the two commands :
echo "hello\\\world"
and
echo -e "hello\\\world"
i get the same output: hello... |
The default is to expand escape sequences, the -e option is non-standard.
If your echo implementation does not include -e in the echo output, it is non-compliant.
The problem here is that there are implementations that only follow the minimal POSIX requirements and ignore the fact that a platform that is allowed to be... | Unix echo command with -e option |
1,599,246,125,000 |
Hi I have a log file that has a lot of information and it is pretty difficult to spot what I am looking for, so I came to this command that show me only what I want to see in the log, it will act as a listener when the pattern is match only show me the search results
tail -f file.log | GREP_COLOR='01;36' egrep --color... |
Preferrably use:
grep -e 'jsonKeyOne' -e 'jsonKeyTwo'
…to OR your terms. Depending on your flavor of grep also -E 'jsonKeyOne|jsonKeyTwo' is possible, too. This is the fastest option with only the terms.
Different colors work like this: first term only colored and all other lines uncolored, next term with different c... | How to tail on demand based on a search and colorized the result |
1,599,246,125,000 |
I saw other posts the same problem, but I can't figure out since everyone does different things. I'm new to shell script as well, so my limited knowledge is getting more confused when I read those posts.
I have this scrip work perfectly well on another server, but somehow on the new server, I need to check different s... |
Seems you have lot of ssh connections...
Try this,
#!/usr/bin/bash
GREEN=0
YELLOW=1
RED=2
pid=(`/bin/ps -eo fname,pid | /usr/bin/awk '{ if ($4 == "abc") print $2}'`)
if [ ${#pid[@]} -gt 0 ]
then
message="sshd Server is running. PID: ${pid[@]}"
status=$GREEN
else
message="sshd Server is stop... | test: too many arguments returns |
1,581,700,593,000 |
Post applying the following OS patch SUSE-SLE-Module-Public-Cloud-12-2020-251 (Security Update for aws-cli) for the month of Feb 2020, AWS CLI was throwing the error SSL validation failed. The command was working fine before applying the OS security patch
Does anybody knows how to fix this issue?
aws s3 ls s3://
SS... |
An upgrade of aws-cli fixed the issue. Below commands, I ran and got the issue resolved.
zypper in python-pip
pip install --upgrade awscli
aws --version
aws-cli/1.17.17 Python/2.7.13 Linux/4.12.14-95.6-default botocore/1.14.17
| SSL validation fails, after applying SUSE-SLE-Module-Public-Cloud-12-2020-251 |
1,581,700,593,000 |
I am trying to clean the cache. I am running linux penguin 4.19.79 using a chromebook. I have run apt clean and apt-get clean to no avail. I get permission design. I have attached a screenshot of the error I get. I'm the root user.
apt clean permission denied
I hope somone can help me. Thank you.
|
When running any command on the 'open' terminal (actually chroot'd inside of its own container) you have to put { sudo apt clean }because the privileges you have are given to you from... well, google I presume. It took me awhile to catch up on that, I have the same on my chromebook. Also, as Mark Stewart said try run ... | How to fix access denied even as owner when cleaning the cache? |
1,581,700,593,000 |
Doing echo -e "\uDDAA" (which is not a valid utf-8 codepoint) in bash, prints ���.
How can I make it not print anything if its not a valid codepoint?
what im trying to do is add in front of all codepoints in NamesList.txt, the character it represents. right now i have it as
sed -e 's/\<\([0-9A-F]\{4,6\}\)\>/\\U\1 \... |
You should not create those sequences in the first place. This will print spaces for control characters (\pC) and give the marks (\pM) a space to ride on:
perl -CO -pe 's{^([0-9A-F]+)\b}{$x=$1,$c=chr hex $x;if($c=~/\pC/){$c=" "}elsif($c=~/\pM/){$c=" $c"}"$c $x"}e' NamesList.txt
(use -i NamesList.txt if you want to e... | stop bash from printing invalid unicode sequences |
1,581,700,593,000 |
How can I check, from the command line, that the audio line output (of a virtual device created with ALSA plugins) has an audio signal? And check the strength of the signal?
|
I've found a solution using the "sox" tool (sox man). I can use the method proposed in this answer (Send sound output to application and speaker) to get the signal in an alsa virtual device call "Loopback" while it's also send to the output device and then use sox to find if there is a signal and it's strength:
sox -b... | Raspbian: Check the sound output |
1,581,700,593,000 |
I am looking at KeePassXC on my Linux Mint Cinnamon system. The installation and initial usage all went well, following the built-in tutorial; but there is a problem with Firefox integration.
After adding KeePassXC-Browser to Firefox, I had an error from the add-on:
Cannot connect to KeePassXC. Check that browser int... |
Since the executable is found under /var/lib/flatpak/app, I am assuming you have installed keepassxc as a flatpak app. As of firejail v0.9.60, firejail does not have flatpak/snap support. See the release notes:
firejail (0.9.60) baseline; urgency=low ...
* drop support for flatpak/snap packages
If you want to sand... | How to use KeePassXC with Firefox and firejail |
1,581,700,593,000 |
I have installed processing-3.5.3 IDE but really want to use the Sublime text editor as my goto for processing sketches. What I have done so far:
Install the "Processing" package in sublime.
Installed processing-java in /home/testuser/Downloads/Compressed/processing-3.5.3-linux64/processing-3.5.3
I believe there mus... |
It looks like you're right, you need to add process-java to your PATH environmental variable. See this detailed guide on how to achieve this, but it should be something like this (though I'd recommend moving the binary elsewhere):
export PATH="$PATH:/home/testuser/Downloads/Compressed/processing-3.5.3-linux64/processi... | How do I fix the "processing-java: command not found" error in the terminal |
1,581,700,593,000 |
So here's an excerpt of my directory tree:
|-- 20070214_014700.a
| |-- info
| |-- processed
| |-- HH.EL..BHZ
| |-- AZ.AS..HHZ
| |-- (hundreds more)
| |-- raw
| |-- resp
|-- 20100737_055560.a
| |-- info
| |-- processed
| |-- raw
| |-- resp
|-- 20190537_028750.... |
find . -type f -path "./*.a/processed/*" -exec sh -c '
for path; do
prefix=${path%%.a/processed*}
cp "$path" "test/${prefix##*/}_${path##*processed/}"
done
' sh {} +
Option -type f searches for regular files in the given path and the -exec option starts a shell script with find's result as arguments ({} +).
In th... | Copying files from specific subsubdirectories based on subdirectory name into single directory then renaming |
1,581,700,593,000 |
all experts
I have two types of files in the same directory
ex1) record1.txt (record2, record3, record4 ...)
11111 absda qwedc
11112 uiyds dqeds
11113 eqwev jfsec ...
ex2) Summary1.txt (Summary2, Summary3, Summary4 ...)
----some data is written----
.....
.....
***RESULT 111.114 30.344 90.3454*** OTHERNUMBER#1 OTH... |
If I undersand you correctly, this is my proposal:
for i in record*.txt; do
xyz=$(grep -oP "(?<=RESULT ).*(?=\*\*\*)" $i)
sed -i "1 iX Y Z\n$xyz\n" summary${i//record/}
done
Loop through the files named record*.txt
for i in record*.txt; do
Capture the string between RESULT and ***
xyz=$(grep -oP "(?<=RESULT ).... | Extracting some texts from txt file and adding to an existing file bash |
1,581,700,593,000 |
We have scripts to reinstall RHEL 5.x to RHEL 7.x and install our application, but I need to update timezone according to old one. So how to restore timezone from RHEL 5.x to RHEL 7.x using /etc/localtime file (We are taking backup) and in command line?
One of the specific environment is Red Hat Enterprise Linux Serve... |
I figured it out. In RHEL 5.x, there is a file /etc/sysconfig/clock contains the timezone. Using sed in the script to get the timezone from that file worked out. Sample output of this file:
ZONE="America/Chicago"
UTC=false
ARC=false
Thanks!
| How to restore timezone from RHEL 5.x to RHEL 7.x? |
1,581,700,593,000 |
I have to repeat this command a lot of times a day, is there any way to execute it multiple times (aprox. 25 times)
cd ../folderName && ../../tools/clone.py
What I need to do is execute the clone script inside every folder I specify.
|
Add this to your shell profile or just try this one:
myclone () { cd $1; /full/path/to/clone.py }
And you can do
myclone ../folderName
| Repeat commands with changes |
1,561,493,692,000 |
Below I run what I expected to be an invalid command: var=3 date, which in fact isn't.
$ var=3 date
Sun May 26 17:10:22 UTC 2019
$ echo $?
0
But the variable wasn't assigned the value 3:
$ echo $var
$
I expected to say that var=3 wasn't a valid command. What am I missing?
|
You are setting var to 3 as an environment variable in the environment of the date command, and not in the environment of the bash shell itself (the calling/parent process).
For refence, see the Bash manual at https://www.gnu.org/software/bash/manual/html_node/Environment.html
and specifically:
The environment for any... | What happens when we run var=3 command [duplicate] |
1,561,493,692,000 |
I have a bunch of folders in an external HDD and I want to copy a part of them. The folders have the following structure:
A001A
A003A
A004A
etc...
...and all the folders contain similar directories e.g:
HHZ
HH1
HH2
LHZ
LH1
LH2
I need to copy all the directories (A001A, A002A ...) with the subdirectories (HHZ, HH1, H... |
This should do the trick (assuming all the directories in the current folder are A*** directories):
cp -r --parents */H* destination/
You should obviously replace destination/ with your actual target.
| Copy specified subdirectories |
1,561,493,692,000 |
I need to write a script in AWK which will count all the files and their weight in "/home" directory from all the months and display the list in terminal.
The output should look like this:
|
I wrote script in awk which uses system commands ls to list files and stat to get info about file. After that script will print number of files and size in bytes.
#!/usr/bin/awk -f
BEGIN {
dir = "/home/matej" #chnage default directory
if(ARGC == 2){ #check for command line arguments
dir = ARGV[1... | AWK- script which lists number and weight of all files created in certain month [closed] |
1,561,493,692,000 |
I noticed while removing httpd package that dependencies installed all not removed along with that
# yum remove httpd
How can i remove a package and dependencies which were installed along with that without affecting other services, like if some dependencies are being used by other services
|
yum autoremove
will remove any unneeded dependencies from your system.
You need to add clean_requirements_on_remove=1 to yum.conf
| Remove Package and dependencies installed along with it |
1,561,493,692,000 |
I have a directory that contains quite a lot of files with names made up of artirst's name and album e.g.:
Now the task is to go through each of the files, create a directory named after artist's name and album the file's name, and move the file into that directory.
The final structure should look like this:
how wo... |
This will mostly do what you want, you are asking for a lot though so let me know if there are any parts you are confused about and I will try to explain them:
#!/usr/bin/env bash
song_dir="$HOME/tmp/songs"
out_dir="$HOME/tmp/org_songs"
[[ ! -d "$out_dir" ]] && mkdir -p "$out_dir"
get_artist () {
local a=($(tr ... | Move all files into subdirectories named after part of file name [duplicate] |
1,561,493,692,000 |
I use Debian 5 and I had to update my GCC to 4.9.4. So I build and installed it by myself. Now I need to update Python but I can't to do that because I receive this error:
configure: error: no acceptable C compiler found in $PATH
Can I link the compiler that I installed to solve this problem?
Also I tried following ... |
/opt/gcc49/bin is not in your path. You need to add it, or use stow.
| configure: error: no acceptable C compiler found in $PATH error on Debian 5 while installing Python |
1,561,493,692,000 |
I'm trying to figure out what this (obretschlt2-w7) is, from my command-line prompt. I'm using a conda environment, with the name µ_env, with my Username mu. However I can't figure out where the 2nd field is coming from. I'm logged into a secure server VPN, through my work, but I don't ever recall seeing this. Wha... |
Is that not your hostname on your system?
Try:
cat /etc/hostname
Edit:
$ echo $PS1 (µ_env) \h:\W \u\$
\h means hostname
Source: wiki.ubuntuusers.de/Bash/Prompt
Command "hostname" may also show your hostname
| What is this random name in my command-line prompt? [duplicate] |
1,561,493,692,000 |
Is there a way/tool for the linux command-line (bash) to get the overall audio playtime of a certain directory?
Something like:
playtime --all --recursive /Music/DrumAndBass/
output: 1:35:06
|
I found a simple way by using the tool mp3info with awk.
Unfortunately this is only working for mp3 files.
mp3info -p "%m:%s\n" directory/*.mp3 |
awk -F: '{a+=$1*60+$2}END{printf"%d:%02d:%02d",a/3600,a%3600/60,a%3600%60}'
or as tiny bash-script
#!/bin/bash
dir="$1"
mp3info -p "%m:%s\n" "$dir/*.mp3" |
awk -F: '{a+=$... | Getting the audio-playtime of a folder from the command line |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.