New answers tagged

0

The select command will try to display every field separated by spaces, tabs, and newline characters. So I don't think your sample will do what you want. You must not use "ls -l" for long listing or the permissions and ownerships and file sizes will all be fields displayed in the select statement results. Not sure if this is exactly what you were looking ...


0

After making the following changes to my dot files, I was able to use emacs style key bindings also inside a tmux session. # .zshrc bindkey -e # .tmux.conf set -g mode-keys emacs set -g status-keys emacs This answer on StackOverflow helped me solve my issue.


0

1. Install / Reinstall Gnome Terminal First we have to determine what the default terminal command is, so let's see what terminal(s) we have installed: $ apt list --installed |grep -i terminal On default 16.04 you should have gnome-terminal installed. If it is not installed, install it: $ sudo apt install gnome-terminal If it is installed, purge and ...


-1

Write the file name using quotes like this "Untitled Dowcument"


-1

nano 'super file.txt' works. Even if you have only terminal ^^


2

You're supposed to type : gedit ~/Untitled\ Document Why? "space" is a character in linux, it's "interpreted" rather than "read". In a succession of arguments in a terminal command, a space will be interpreted as or will mean: "now I will pass the next argument". With this in mind, your gedit did exactly what you told it to do, first edit a document ...


3

The -o option which you want was added in 2017. Your version is from 2016. You need to upgrade. Details Note the year in your version message: Copyright (C) 2016 Free Software Foundation, Inc. Now, look at this section from the findutils ChangeLog: 2017-06-08 Bernhard Voelker <mail@bernhard-voelker.de> xargs: add -o, --open-tty option ...


2

You could use something like this. It works for files with an arbitrary number of columns, assuming that the first column is text and shall have SUM in the result line instead of the sum of all values of that column. $ awk '{for(i=2;i<=NF;i++)a[i]+=$i;print $0} END{l="SUM";i=2;while(i in a){l=l" "a[i];i++};print l}' data.csv > final.csv A 5 3 B ...


1

Found something that at first didn't work for me on StackOverflow https://stackoverflow.com/a/27110024/2161301 awk -F',' '{ print($0); len=split($0,a); if (maxlen < len) { maxlen=len; } for (i=1;i<=len;i++) { b[i]+=a[i]; } } END { for (i=1;i<=maxlen;i++) { printf("%s,", b[i]); } print "" }...


0

ID=$(aws ec2 describe-addresses --region us-west-2 --query 'Addresses[].AssociationId[]' --output text >> AId.txt) IP=$(aws ec2 describe-addresses --region us-west-2 --query 'Addresses[].PublicIp[]' --output text >> OIP.txt) read -a array <<< $(cat AId.txt) touch NR.txt for i in ${array[@]}; do echo $(aws ec2 describe-addresses --region us-west-2 -...


0

I found the answer here, it turned out I needed to figure out how to install the timezone (tzdata) program non-interactively, rather than cimg. For those interested my script is apt-get update -y apt-get upgrade -y apt-get install -y libx11-dev export DEBIAN_FRONTEND=noninteractive ln -fs /usr/share/zoneinfo/Australia/Brisbane /etc/localtime apt-get ...


1

Pipeline character, | indicates OR, i.e., either of the two lxqt-sudo and gksu can be used. Similarly, xfwm4 or x-window-manager and firefox or www-browser.


0

The same thing was bugging me, so I'll answer this old question. I've found that xdg-open and gio open have trouble with this sort of script, and I've also noticed gnome-terminal has trouble with it. For example, xdg-open can open gedit to edit text files, but not evince to view pdfs. So I use the following script with xterm -e. Note that this will leave ...


0

Install synaptic. You can then browse packages by "origin" or even any other custom filter.


0

If you have a look at the files provided by php-7.2-pgsql, you will see that the pdo_pgsql is part of the php7.2-pgsql-package. pdo_pgsql is a php module. You enable php-modules by adding them to the php.ini, as you seems to have done from what you write. In general: if you can add a module to php.ini, and not get exceptions when using PHP, then the ...


10

I think you have created a file with the name /dev/sdb. If that is the case, there is a regular file, where you expect there should be a block device. It should be possible to remove that file and after that (maybe after a reboot) your system should be able to create a block device /dev/sdb


2

Actually no need flint. Just do md5sum and a get list of I/O errors, then process to delete those files. ~/usr/mnt5/DCIM/104APPLE$ md5sum * md5sum: IMG_4001.JPG: Input/output error md5sum: IMG_4002.JPG: Input/output error md5sum: IMG_4003.JPG: Input/output error md5sum: IMG_4004.JPG: Input/output error md5sum: IMG_4005.JPG: Input/output error md5sum: ...


0

First remember that given any two lists, there are 3 types of difference that we can calculate: elements that are in List 1, but are not in List 2 elements that are in List 2, but are not in List 1 elements that are in one list, but not both (symmetric difference) The standard Unix tool to compare lists (files) line-by-line is comm. It normally outputs 3 ...


0

I used the combination to get it to do what you want: Generate the arrays with: l1=$(cut -d" " -f 1- src1.txt) l2=$(cut -d" " -f 1- src2.txt) Use the command like this to compare both arrays: l1=$(cut -d" " -f 1- src1.txt) && l2=$(cut -d" " -f 1- src2.txt) && echo "${l1[@]}" "${l2[@]}" | tr ' ' '\n' | sort | uniq -u | xargs -L 2 > ...


0

It seems you have two files with a huge line each, which contains (space) separated tokens. The diff tool is good for line matching. For items within the line you will have to be a bit more creative. For example :~$ cat file1 a b c d :~$ cat file2 b d :~$ cat file1 | sed 's/ /\n/g' |grep -vf <(cat file2|sed 's/ /\n/g') | tr '\n' ' '; echo a c we ...


0

Actually, when running Ubuntu under VirtualBox, you will need to do: gsettings set com.canonical.Unity lowgfx false Editing the config file will only temporarily change it.


0

It seems to have been a problem with either Termite or the vte-ng library. Solution here: https://askubuntu.com/a/1010348/971943


4

No, that's not safe or common at all. Historically python refers to python2, not python3 Many python(2) scripts will break if run using the py3 interpreter The reverse is also true: Many py3 scripts will break if run using the py2 interpreter. There is no graceful failure - a script run using the wrong interpreter simply spits out a series of cryptic error ...


1

Using fish, the other answers didn't work for me. But this did: set PATH $PATH /home/me/pycharm-edu-4.0/bin/


1

Because _ is a valid character for a variable name, you need to use the ${varname} syntax to let the shell know the end of the variable name. Otherwise, you have $i and $_logfile as variables, but the latter is empty. The syntax $i$ does not exist. Use: setsid python main.py 1>data/${i}_logfile.txt 2>&1 Note that $variable is actually a ...


0

There is a nifty utility for precisely this task: https://bitbucket.org/eradman/entr/src/default/


0

Apt is the newer version of the command. You should switch to using apt instead of apt-get its better and gives better idea of what the command is doing. As for apt-full-upgrade and apt-get-dist its the same command. But again apt is the newer command. For example when using apt you get a progress bar to tell you how much of the install/update is done.


0

You likely shouldn't do that. You can probably achieve your goal in way that does not involve writing one script that generates another script that you will later modify and run; see below. But if you really want to do it, and you want to do it with code that closely resembles what you've shown, then steeldriver is right that a here document is a workable ...


0

Use a here document, making sure to quote the delimiter word so that the shell does not expand anything in the body: #!/bin/bash cat << 'EOF' | sudo tee -a /usr/local/sbin/adduser.local #!/bin/bash lastuser="$(grep home /etc/passwd | cut -d: -f 1 | tail -1)" EOF The use of tee is because sudo echo "..." >> somefile doesn't do what you ...


0

If you want to just copy all of the files from one dir to the other recursively, you can use something like this: cp -r /home/user1/dir1/* /var/www/dir2/ If you wanted to copy the entire directory recursively, it would look more like this: cp -r /home/user1/dir1 /var/www


2

You can use the unzip command with its -l option. man unzip says about the -l option: list archive files (short format). The names, uncompressed file sizes and modification dates and times of the specified files are printed along with totals for all files specified. For example you are in ~/sed directory,in which there is a zip file named my....


0

It looks like you are using redirection incorrectly (output of docker load redirected to alpine.tar): docker load>alpine.tar I would suggest that you download alpine.tar from the other machine again (since it could be corrupt now) and then use docker load -i alpine.tar instead. Since the image isn't loaded correctly, it would explain why the create ...


5

Using tmux: I use tmux in vi mode: Go to copy mode (in my config Prefix+escape, Default Prefix is Ctrl+b) In config file (~/.tmux.conf): bind Escape copy-mode Move around (Using arrows) Select your desire output (Start selection with Space) In my config v: bind-key -T copy-mode-vi y send-keys -X begin-selection Press Enter to copy the text. In my ...


1

TL;DR: You can extract the whole archive with tar xf. As Rinzwind mentioned, bunzip2 unfortunately refuses to operate on symbolic links. The output of file revealed that your .bz2 file is a symlink rather than a regular file. How you should go about decompressing the file depends on specifically what you want to do. Considering the particular file you are ...


2

For quickly executing commands, use ALT+F2 and type your command there. Be careful as some functionalities like redirecting output into files might not be working as expected.


9

Use tr: tr -s ' ' '\t' < file1 > file2 -s, --squeeze-repeats replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character


0

I know its funny but associate on some instruction on other solution I try to open some file with nano and terminal CHARSET have been changed to default view. I don't know why and not any idea on this problem.


2

Try the reset command, ie. just type reset into your terminal to reset. The command clear could also work, but it's primary function is to clear the display, where reset is really what you want. It's really useful if you're coding and using escape characters to change something in the terminal by make a typo & screw something up, or you cat a binary ...


6

If you want the tab character, use \t as the replace pattern instead of ,. If you want just one tab (or comma) to replace multiple spaces, add \+ after the space: sed 's/ \+/\t/g' file1 > file2


4

You do this by escaping the newline character, add a backslash \ directly before the line break: python file_a.py file_b.py \ file_c.py file_d.py You may indent the second line to further improve readability: python file_a.py file_b.py \ file_c.py file_d.py


0

Removing chrome remote desktop was the solution for me - locale was fine, uninstalling and reinstalling did nothing, .bashrc was the same in ~ as it was in /etc/skel. XTerm and UXTerm would launch and from there I could dbus-launch gnome-terminal successfully, but I had to $ sudo apt remove chrome-remote-desktop AND reboot to get gnome-terminal to launch ...


2

The answers so far assume that files only go into a directory and never go out. But what if you have a script that empties the directory periodically? Then the script could miss the fact a file went into the directory 5 minutes ago but was processed and taken out. Another option is using the inotifywait command written in highly efficient C language for the ...


2

Kitware now has an APT repository and currently supports Ubuntu 16.04 and 18.04 Install Instructions: Remove old version of cmake sudo apt purge --auto-remove cmake Obtain a copy of the signing key wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - Add the repository to your sources list a. For Ubuntu ...


2

When you press Ctrl+Alt+F7, you're switching to a different tty or virtual console. These virtual consoles work much like a Terminal, such as gnome-terminal or xterm, except they aren't loaded by your Windows Manager, and you will likely need to login to them. Be warned, if you login and fail to log out, that tty will stay active and someone else can just ...


0

ctrl+w does not delete but cuts everything in front of the cursor. Therfore you can yank/paste it with ctrl-y assuming you did not move the cursor. ctrl+_ actually restores the line itself.


1

You are running a bash script as an sh script. You haven't shown your actual script, but based on the error, I am guessing you either have an sh shebang: #!/bin/sh Or you are calling the script with sh instead of bash: sh yourScript.sh The <() operator you are using is a bash feature and isn't available in the sh shell (which is a basic shell called ...


2

Since there are no characters in your regex pattern that the shell will expand when inside double quotes (such as $ or ! for example), you can simply use double quotes around the whole expression: $ echo "foo 'bar' baz" | sed "s/'bar'/'BAR'/" foo 'BAR' baz See for example Single quote within double quotes and the Bash reference manual


0

I tested this from ubuntu bionic beaver and android lollipop. First on your ubuntu install the needed packages: sudo apt install bluez bluez-tools bluez-tools come with the following tools: bt-adapter bt-agent bt-device bt-network turn on the visibility of your ubuntu: bt-adapter --set Discoverable 1 from the smartphone scan for remote devices to id ...


2

The queston boils down to "How do I quote/use single quotes inside a single quoted string"? This answer over on stackoverflow.com explains it. Use sed -r -i.1 '/(^Commandline: packagekit role='"'"'update-packages'"'"'|^Commandline: apt-get --no-upgrade| ^Commandline: apt full-upgrade| ....| ^Reinstall )/d' ...


2

Before checking for new files, I would use "stat" on the directory itself and see if the timestamp changes. $ stat $PWD File: ‘/home/paulm/SCRATCH’ Size: 6144 Blocks: 8 IO Block: 32768 directory Device: 26h/38d Inode: 10937103831396301849 Links: 6 Access: (0775/drwxrwxr-x) Uid: ( 520/ paulm) Gid: ( 1020/ paulm) Access: 2019-07-...


Top 50 recent answers are included