All Questions
216
questions
0
votes
2
answers
105
views
bash + how to insert date before line
lets say I want to pipe the date output in the beggining of some text
for example
echo "this line is test line" | date
and expected output should be
Wed May 22 14:55:10 UTC 2024 this line ...
2
votes
1
answer
303
views
How to Print, when columns have spaces - awk?
Problem:
desired columns have text with spaces SAMSUNG MZNLN128HCGR-000H1
undesired columns have text with spaces, see VENDOR = M.2 SSD
awk only printing the first word.
awk not printing the column ...
0
votes
2
answers
466
views
awk string replacement - properly escape '&' character
I am working on one of our applications to update the docker image from using static configs for each environment to a single template using dynamic variable insertion with awk. Our Dockerfile calls a ...
2
votes
2
answers
343
views
I want to get every command that has 3 letters and only three letters
I don't get the output I expect using apropos -k . |awk '/^.../ {print $1}' am I completely overthinking this? In this sample output only zsh should have come back.
I also tried this
apropos -k . | ...
0
votes
1
answer
590
views
Moving files to a directory with spaces in its name
I'm trying to create a directory that has in its name the beginning of the names of the files it contains. I need this in order to archive it later. I have run into problems when moving files if the ...
1
vote
1
answer
98
views
How to parse upload and download speed with ifstat and printf?
In bash I'm trying to display rounded (no decimals) download and upload speed in readable format i.e something like that:
Download 16KB Upload 200KB
I got this but its not quite working:
ifstat 1 1 |...
0
votes
2
answers
1k
views
Find and replace string in a file using 'sed' or 'awk'
Let's say I have the following input file:
yhara.runner.mng1.nna1.X9HCJG.1 yhara.runner.mng1.nna1.Z2HCJG.1 100.000 100
yhara.runner.mng1.nna1.X9HCJG.1 yhara.runner.mng1.nna1.AUEM0K.1 94.144 72
...
0
votes
1
answer
337
views
Loop with awk output field
the output of my script
grep 'Interface GigabitEthernet' * | \
sed 's/104-8-20-23.lightspeed.gnvlsc.sbcglobal.net/104.8.20.23/g' | \
sed 's/0.0.0.0: //g' | \
sed 's/.log:/ /g' | \
sed 's/Line protocol ...
1
vote
2
answers
314
views
Multiply numerical value after a string in a json file by 3?
I'm trying to replace a number in a set of text files. The number will be different for each file, but it will always occur after a specific string.
Here's the original file:
"structures&...
3
votes
4
answers
336
views
How to remove all newlines from a file?
I have the command cat file.txt | gawk '{print $2}' > test which displays:
1
1
0
0
1
1
Afterwards:
vi test
:%s/\n//
Which outputs: 110011
My question is I don't know how I could incorporate this ...
-1
votes
1
answer
169
views
write a efficient for loop in bash for multiple files (.PDB files)
I have problem with this script:
#!/bin/bash
for filename in /home/hb/pg/ensemble/pdbs/P24941/raw_pdb/*.pdb; do
grep COMPND $filename | grep "CHAIN:" -B 1 | sed 's/COMPND//g' | sed 's/...
0
votes
2
answers
542
views
Are linux commands (grep, awk etc) part of the system, or the shell?
I'm a developer, so I know my way around a terminal, but I never really dove into it. I can write bash scripts (albeit on a beginner level, not my area of expertise), but I now need to understand ...
1
vote
1
answer
399
views
How to find the "pattern" in FASTA file and record the cordinates along with header
I am looking for a solution to search for a string of 17 base pairs in the FASTA file that is the human reference genome.
To clarify, in simple words and put the resources, i have tried grep function ...
1
vote
2
answers
609
views
Delete lines between two patterns (with multiple occurrences) around a third pattern (single occurrence)
I'm trying to edit an uncompressed PDF on macOS Monterey, and I want to delete objects that contain a certain pattern in their description. Such objects start with "X 0 obj" (where X is the ...
2
votes
0
answers
943
views
Find and replace multi-line block in multiple files (bash/linux)
I'm trying to find a way to find a text block that meets the criteria:
block starts with "google = {"
block ends with next "}" character found - ignoring everything else.
Example
...