Skip to main content

All Questions

Tagged with
1 vote
1 answer
64 views

Why can't I run an interactive command in awk in a pipeline?

Consider the following commands: $ awk 'BEGIN { system("ed") }' q $ echo hello | awk 'BEGIN { system("ed") }' ? $ In the first case, I was able run ed and then stay in the editor ...
mbigras's user avatar
  • 3,422
0 votes
2 answers
91 views

Adding up sizes of directories using bash is inconsistent

First, I got the total size of folder /my-downloads: $ du -sh /my-downloads 304G /my-downloads As you can see, it's 304G. Then, I wanted to find out the total size of all immediate directories ...
Logan Lee's user avatar
  • 249
-1 votes
3 answers
111 views

filtering command output with awk

I want to extract the hostname (rd5044) from the output of a psql command like the below: postgres@internal-rd5112:/opt/db/postgres/bin> psql -p 5434 -tc "SHOW primary_conninfo ;" user=...
vrms's user avatar
  • 253
1 vote
4 answers
225 views

Trying to parse output of "lastb" command via awk, but when the userID field is blank, my variables are thrown off

I'm trying to pull the date and IP address from the output of lastb I'm using: lastb | awk '{print $5,$6,$7,$3}' The problem is that sometimes the first column (userID) of lastb is blank: Data ...
ZacWolf's user avatar
  • 183
2 votes
1 answer
455 views

Extract file path from Git diff output

I have the following command: git diff branch1..branch2 | grep '^diff' ...that will output files that contains differences between two branches. Sample output is like this: diff --git a/path-to-file1/...
MrSnrub's user avatar
  • 237
2 votes
3 answers
434 views

Replace prefix string from lines in a file, and put into a bash array

In the file groupAfiles.txt are the lines: file14 file2 file4 file9 I need a way to convert them to remove file and add /dev/loop and put them all in one line with a space between them. /dev/loop14 /...
user447274's user avatar
2 votes
1 answer
33 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
2 votes
1 answer
186 views

Why does a 'pipe-to-awk' behave differently inside a function?

I'm using alsa to fiddle around with the volume on a Bluetooth speaker I have connected. It's a 1-speaker setup; just something to provide some background. I can 'get' the volume setting fm the CLI as ...
Seamus's user avatar
  • 3,727
0 votes
2 answers
103 views

Replace multiple lines in a file with another command

I can find all files in a directory with a particular name with find: find . -name hello.mk Inside each hello.mk I need to replace lines 9 and 10 with a single line, as shown below: 9: ...
cybertextron's user avatar
1 vote
4 answers
130 views

BASH variable inside AWK that is itself an AWK command

I want to use a BASH variable inside AWK that is an AWK command. Here is my test code that I plan to make more complicated if I can find a solution to this problem. exptransform=( 'print \"...
dantepicchioni's user avatar
0 votes
4 answers
112 views

How to replace pattern in last line

I'm trying to replace "}," by "}" from the last line of a file : My /etc/firefox/policies/policies.json file like this because I added the certificate lines using a for loop : $ ...
SebMa's user avatar
  • 2,401
1 vote
6 answers
668 views

Bash script that takes multiple path arguments and checks if files can be successfully created there

I would like a bash shell script (for my Debian 12 system) which accepts multiple paths as arguments, and then checks if a file can be successfully created in each one. Then the result should be put ...
teeeeee's user avatar
  • 293
-2 votes
4 answers
112 views

How to get either a substring or a text value using awk and if?

I can't figure out how to write a simple ping log. I only need either the ms value or the words "no connection". I have myping=$(ping -c 1 10.0.10.1). I only need the value between "...
Gary U.U. Unixuser's user avatar
0 votes
2 answers
116 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
-3 votes
1 answer
77 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

15 30 50 per page
1
2 3 4 5
68