Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
72 views

How exactly are results being passed among processes via the pipes?

So Unix follows a uniform approach to I/O that allows programs to connect via pipes. I also know that to do that it uses file descriptors. But I heard someone saying that pipes allow attaching the ...
smith's user avatar
  • 121
0 votes
2 answers
103 views

How to sum all disk size in Linux?

We have some Linux servers with several disks. [root@xxxxx~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 ...
Astora's user avatar
  • 459
6 votes
1 answer
719 views

bash pipe loses data when command crashed

Consider this simple program (abort.py) that writes some text to stdout and stderr and then crashed (abort()). import os import sys print("end stdout") print("end stderr", file=...
lewisxy's user avatar
  • 171
4 votes
1 answer
533 views

How can I use a terminal emulator as an efficient application launcher?

The Problem I've used various application launchers like rofi, albert, wofi, dmenu, and others throughout my Linux years. While they have their pros and cons, one thing has always bothered me: they're ...
chedieck's user avatar
2 votes
1 answer
163 views

select in a script

In Linux in Bash in a Script i use this: #!/bin/bash while true; do while true; do read -r -p 'enter number [4-999]: ' num if [[ $num =~ ^([4-9]|[1-9][0-9]{1,2})$ ]]; then ...
user447274's user avatar
0 votes
0 answers
32 views

Why does `if [ -d $EMPTY_VAR ]` return true? [duplicate]

I have written a Bash script which doesn't behave quite as I expected. It contains the following lines of code. TARGET_FOLDER=$1 echo "TARGET_FOLDER: $TARGET_FOLDER" if [ ! -d $TARGET_FOLDER ...
user3728501's user avatar
-4 votes
2 answers
108 views

How to write in Linux in Bash in shellscript a part that can do something like this

How to write in Linux in Bash in shellscript a part that can do something like this enter a number must be in a range from 4-999 if not, ask again to enter enterednumber * 5 * randomnumber [1-9] (...
user447274's user avatar
0 votes
0 answers
34 views

How to only suppress warning outputs from cryptsetup?

In Linux in Bash i run a script with some cryptsetup calls like --luks2-metadata-size=16k --luks2-keyslots-size=256k .... luksFormat .... that brings Warning outputs. I know and understand, but i ...
user447274's user avatar
1 vote
1 answer
30 views

How to see the content of an appointment in a queue of commands of AT command

I know i can see the schedule with atq, but this brings me only the timedate of the execution and not wich command wil be executed. [root@myserver ~]# atq 1Thu Oct 31 04:45:00 2024 a root Using at -...
A_Figueiredo's user avatar
2 votes
1 answer
27 views

subset my .fam file using a .txt file of names

I have a .fam file in plink format, looks like this 1 I001.HO 0 0 1 1 2 I002.HO 0 0 1 1 3 IREJ-T006.HO 0 0 1 1 4 IREJ-T009.HO 0 0 1 1 5 IREJ-T022.HO 0 0 1 1 6 IREJ-T023.HO ...
Savannah Hay's user avatar
0 votes
1 answer
46 views

Open 2 mate-terminal instances and run commands

I am trying to set up a script that runs 2 mate-terminal instances, each with a different command. The script is set up as a cronjob. The problem is, while the script works fine when executed manually,...
daydr3am3r's user avatar
0 votes
0 answers
27 views

how to change error (std-err) color [duplicate]

Because standard error is a separate device in UNIX-like environments, and programs or shell scripts can redirect their errors to it, it would be logical to configure terminals (any displayer) to ...
Sm D's user avatar
  • 1
4 votes
2 answers
280 views

How to find and list all symlinks in a short form?

I have a large set of directories and files, along with many symlinks that typically point to a directory called "shared" or to a directory or a file underneath the "shared" ...
codeforester's user avatar
1 vote
2 answers
57 views

How to loop over a list of extensions to check that files of each type exist?

I have the following directory structure: main_dir/ │ ├── randstr1.randstr2.tar.gz │ ├── randstr3.randstr4.tar.gz │ ├── randstr5.randstr6.tar.gz │ ├── randstr7.ext2 │ └── randstr8.ext3 ...
teeeeee's user avatar
  • 229
1 vote
1 answer
97 views

add a randomize option in a bash script

in a bash script i do run this: seq 1 $(<howmany.txt) | xargs -I% -n1 -P$(<parallel.txt) mycommand --infile file% --option A --outfile file%.new it works. the values in howmany.txt and parallel....
user447274's user avatar
1 vote
1 answer
78 views

Why does tar command create this directory structure when extracting a tar file?

I have created this simple directory structure: $ tree testdir/ testdir/ ├── subdir1 │   ├── file1.txt │   └── file2.txt ├── subdir2 │   ├── file3.txt │   └── file4.txt and would like to archive the ...
teeeeee's user avatar
  • 229
0 votes
3 answers
95 views

how to process a sequence of items in groups of N at a time

Sequentially one after another: for i in $(ls -1) ; do command $i ; done All at one time: for i in $(ls -1); do \ ( \ command $i ; done ; \ ) & \ done; wait How to say only for example 4 or ...
user447274's user avatar
0 votes
2 answers
41 views

Capture and print on the exact match from a file

I am trying to use grep to match only a specific part of a row in a file. The file is a huge csv file with some columns containing json with commas so it is hard to figure out which column what I am ...
smith's user avatar
  • 121
4 votes
2 answers
282 views

Invalid date when setting one computer's clock from another

I have the following code in a Bash script, which takes the current date/time and sets it via SSH on a target computer: ssh <user>@<target> "date --set '$(date)'" This was ...
Richard Whitehead's user avatar
0 votes
1 answer
88 views

How to add some random data at certain places in a file

With my Computer, it runs a Linux kernel and bash, i will make a technical-experiment. I have a file, file.dat, size = 1.048.576 byte. I will add at certain places in file.dat some irregular (1...8 ...
user447274's user avatar
0 votes
2 answers
62 views

How to append multiple wildcard outputs into separate lines using echo?

very very new to Linux as a whole and doing some relatively simple exercises in bash. I cannot for the life of me figure out how to take multiple outputs from the wildcard character (*) and copy them ...
Ethan Matz's user avatar
0 votes
1 answer
70 views

How to prevent a Linux shell from intercepting escape sequence so it can be sent over serial TTY

I am working on an embedded system that is connected over USB serial TTY (i.e. /dev/ttyUSB0), which needs to interpret arrow keys sent via a virtual terminal such as screen. The problem is, the shell (...
Antennae's user avatar
1 vote
0 answers
36 views

Going to the direcory of a file as fast as posible [duplicate]

Is there a way to get to the path of a file as fast as possible and in the least amount of keystrokes. Context: Type cd and then paste the path of a file and then have to go back and hit backspace ...
GumGun's user avatar
  • 11
0 votes
2 answers
107 views

How to copy the value from one "column" to another in Bash?

I have a file with lines: username="user1" email="[email protected]" I need to take the username from the email address and replace the username value with it, so the end result ...
Vladimir Terentyev's user avatar
-2 votes
2 answers
49 views

Remove last 9 character in alternate lines of file in unix

I need to remove last 9 character from a file starting from Line number 4 and remove only on alternate lines 6,8.. like that to last Line of file
Arsenal's user avatar
0 votes
1 answer
123 views

Strange bash errors for root console

Frequently, when switching my user by root with su -, I get strange bash error messages in the rxvt console, or even in a TTY. They happen even after a complety system upgrade from scratch, so it is ...
Luis A. Florit's user avatar
1 vote
2 answers
59 views

How to modify this git alias so it can be run without the need to put multiword commands in quotation?

I have this alias: git config --global alias.all '!f() { ls -R -d */.git | xargs -I{} bash -c "echo {} && git -C {}/../ $1"; }; f' It currently works fine when I run it like : git ...
Codrguy's user avatar
  • 133
-3 votes
1 answer
76 views

How to convert multiple columns to rows in shell (unpivoting)

I have a tab separated table with hundreds of columns and rows, like that: OTUId AC0184 AC0250 AC0257 AC0258 AC0262 AC0263 AC0289 AC0293 OTU549024624 51659 0 0 0 0 0 0 0 OTU565712448 108 0 0 0 0 0 0 0 ...
babinecha's user avatar
1 vote
2 answers
68 views

Use sed to insert a character in an xml file

I have an xml file with content following this format: <type:color>000000</type:color> <type:color>FFFFFF</type:color> The information within the tags are hex colors (many ...
jon danniken's user avatar
-2 votes
2 answers
255 views

runuser: execute commands without use of quotation marks?

Overview I'm attempting to execute commands as a different user without using quotation marks as well as making sure the executed command isn't inheriting environment from the parent shell. runuser ...
GrabbenD's user avatar
  • 150
0 votes
2 answers
117 views

How can I properly harden my system against some basic exploits like modifications of .bashrc?

I recently read a section on bashrc in the ubuntuusers wiki, in which a possible attack vector for privilege escalation is pointed out. Attackers, or malicious programs, could modify the bashrc or ...
hefe's user avatar
  • 193
-4 votes
3 answers
125 views

show which of a list of filenames do not exist in a given list of directories

I have a long list of filenames like 20231121_150111.jpg... in a text file (one filename per line). And another list of directories. Those directories contain files. How can I check and show which ...
user447274's user avatar
16 votes
5 answers
1k views

How can UserA programmatically replace a text string within a file they own that's located in /etc?

A non-root linux user owns a text file that's located in /etc, where the non-root linux user does not have permission to create files. The non-root linux user can edit the file manually via vi without ...
Tortoise Pirate's user avatar
-3 votes
1 answer
246 views

Find files in a directory modified in the last 24 hours without using the "find" command [closed]

Is there a way to find the files modified in a specific directory in the last 24 hours without using the find command, using only the ls command?
Sebastian Llaurador's user avatar
0 votes
1 answer
73 views

Running command 'cat /proc/<pid>/stat | cut -d" " -f29' to get stack pointer , is always showing stack pointer as zero

Iam trying to get the stack pointer of some thread using the /proc//stat, whenever i run the command,cat /proc/<pid>/stat | cut -d" " -f29 i end up getting zero, but when i run sudo ...
Hodgson Tetteh's user avatar
12 votes
2 answers
5k views

Check if current user can run sudo without requiring a password

I want to check if the current user running a BASH shell script has access to passwordless sudo or not. If they don't, I'd rather have the script exit rather than prompting them for a password.
Jay Taylor's user avatar
1 vote
0 answers
217 views

Bash terminal lagging one input behind

After a recent update, I've noticed that working on any terminal for more than a few minutes causes a delay between inputting a keypress and seeing it reflected on the screen. Specifically, if I were ...
Nick Reed's user avatar
  • 173
0 votes
1 answer
68 views

Bash script to find certain files and add their names to another file

When I find a file whose size is 12kb I want to copy the file name to new file input.xml #!/bin/bash if [ $(find /root -type f -size +12k) ] then grep -r -i -s "the name of file to find it&...
IceDarkness's user avatar
0 votes
0 answers
74 views

keep sudo effective without password after update sudo package itself

I want to write an automation script in Bash that requires frequent use of the sudo command. To avoid entering my password repeatedly after the sudo timeout, I've tried the following: #!/bin/bash sudo ...
anonymous's user avatar
  • 187
0 votes
1 answer
41 views

Looking for assistance in expect

I have a bash script that has expect to login to a remote host and run list of commands. It works as expected. It has a flaw, if the user enters the wrong password, the expect script keeps trying the ...
Vra's user avatar
  • 1
-2 votes
3 answers
196 views

Bash script: echo output of variable and write to file

I am trying to write a script which will check to see if the contents of a file match a certain value and if so, overwrite it with contents of another file. Example: file1 = A, B, C, D 1, 2, 3, 4 ...
Joseph Woodward's user avatar
0 votes
0 answers
42 views

Command 'cdh' not found appearing at the top of CL when opened

I am new to Ubuntu, and I am using the latest version. Initially, I wanted to create an alias, using: alias cdh='cd /home/[My name]/' This was done since I wanted to download video files to a ...
CurrentBitMiner's user avatar
1 vote
1 answer
32 views

Diagnose bash autocomplete issues

I have one binary on my system, fio installed via package manager which doesn't autocomplete files with tab once you've typed fio . I guess this means something must over overridding the autocomplete ...
BeeOnRope's user avatar
  • 559
4 votes
1 answer
387 views

pipe to a different file descriptor

Following up on Using while loop to ssh to multiple servers, i.e., for while IFS= read -r -u9 HOST ; do ssh "$HOST" "uname -a" ; done 9< servers.txt which reads from a ...
xpt's user avatar
  • 1,736
0 votes
0 answers
44 views

Using comma separated list to ssh [duplicate]

Following on https://unix.stackexchange.com/a/511859/374303, whose answer is: while IFS=, read -r IP ID NAME; do echo "ssh $IP myprogram $ID $NAME" done < testfile.txt However, my ...
xpt's user avatar
  • 1,736
0 votes
2 answers
76 views

extract a column from the command output even if it blank bash

I am trying to extract 2nd column from a command output For example: $ sudo /usr/sbin/pvs PV VG Fmt Attr PSize PFree /dev/sdc1 vgswap lvm2 a-- 16.00g 0 /dev/sdc2 ...
Vija200's user avatar
2 votes
3 answers
110 views

can nohup and disown both still let program run after exiting the shell

I'm discovering the difference between nohup and disown in Ubuntu's bash. I have while.py. import time while True: print(1) time.sleep(1) First, I used ssh to connect to my ubuntu server and ...
Kartone's user avatar
  • 51
1 vote
1 answer
80 views

How to Set Up Individual Bash History Files for Each Container Alongside a Unified History File?

In my current setup, all of my bash histories are stored in a single file, which is pointed to HISTFILE. This history includes a history of the host system and all containers. Along with this history, ...
Compiled's user avatar
4 votes
1 answer
181 views

Will writing to /dev/pts allow me to source ~/.bashrc?

I have several terminal windows already open; I just made a change to ~/.bashrc, and I'd like to run source ~/.bashrc in each of the open terminals. It seems to me that if I just source ~/.bashrc | ...
Radoslav Ivanov's user avatar
2 votes
1 answer
154 views

How to run python script on login

I am attempting to load a python script that launches a Firefox Geckodriver under Selenium whenever a specific kiosk user logs in to the GUI. I've tried launching this via .profile, however ...
Firav's user avatar
  • 31

1
2 3 4 5
58