Skip to main content

All Questions

Tagged with
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 votes
3 answers
98 views

Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all

On a Linux machine with GNU tools I have an ascii file that consists of only 2-line and 3-line paragraphs, each paragraph separated by a newline. All 2-line paragraphs are to be deleted so that all 3-...
stampeder's user avatar
1 vote
3 answers
82 views

Bash: sum a number present in N lines before a given pattern

I have a kdenlive project file (which is basically a xml file) with a lot of text clips inside. I need to bulk edit the x coordinate of a certain text that appears multiple times. This is an example: ...
baiserekku's user avatar
6 votes
3 answers
931 views

awk: sort by first column then second; output unique 1st column once but all 2nd column

I have a two-column file that you can create as follows cat > twocol << EOF 007 03 001 03 003 01 137 12 001 11 002 01 002 02 002 03 001 02 002 04 137 94 010 21 001 01 EOF The resultant file, ...
bballdave025's user avatar
-2 votes
3 answers
127 views

bash + how to verify folders under specific path are ended with number/s

I want to check the folder/s under /var/kafka that all them are ended with number otherwhile I will exit with error ls -ltr /var/kafka drwxr-xr-x 399 kafka kafka 28672 Nov 9 13:10 data6 drwxr-xr-x ...
yael's user avatar
  • 13.9k
-1 votes
3 answers
168 views

Replace new lines at end for those lines whose 2nd field in colon separated file span over to multiple line

I have got multiple files with different set of contents but the pattern is same across mulitple lines in different files. sample input file : cat -n test.txt 1 adjfkhjdhfkjd: ...
Ashis Sahoo's user avatar
1 vote
6 answers
1k views

Find and replace a multi line text file in another multi line text file

I fought with it for so long but I am now completely out of ideas. Maybe someone here will be able to help me. Here is what I want to achieve: file_1.txt: # Some comment some_variable="test" ...
Peksio's user avatar
  • 121
3 votes
2 answers
342 views

Squash file with key-value records to CSV [duplicate]

I want to write a data parser script. The example data is: name: John Doe description: AM email: [email protected] lastLogon: 999999999999999 status: active name: Jane Doe description: HR email: [email protected] ...
annahri's user avatar
  • 2,126
3 votes
2 answers
405 views

Collapsing a series of comma separated numbers in a sequence to Beginning-End [duplicate]

Problem I am trying to solve/enhance a BASH script that provides a number sequence: I am using a topologically aware tool (lstopo-no-graphics) to extract physical processor numbers to use for input to ...
Goomba1050's user avatar
0 votes
1 answer
927 views

Capturing hostname & data when executing local script on remote server

While trying to execute a local script on remotely host unable to get hostname of the remoteserver to a local output file. For example I am executing a script below. ssh remotehost sh -s < sudo su -...
AReddy's user avatar
  • 3,208
3 votes
6 answers
1k views

Passing variable to AWK not working inside a loop

I have this awk statement that reads a YAML file and outputs a particular value. I need to loop this awk inside a loop where I read a key value from a list of values and pass that key to awk. The YAML ...
user3674993's user avatar
-1 votes
3 answers
663 views

linux + print the root file system size

lvs is good command to show us the file system size as lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv_root vgW -wi-ao---- 100.00g lv_swap vgW -wi-ao---...
yael's user avatar
  • 13.9k
0 votes
1 answer
47 views

Concat line with next line if both contain the same number of a specified character

I need to concat lines which contains a specified number of the specified character. I don't have any idea, it's easy in python or ruby, but I want to do this using perl / sed / awk / bash, without ...
TheAnotherWise's user avatar
6 votes
6 answers
4k views

Elegant way to merge lines with multi-char-delimiter, ignoring blank lines, supporting \n, \r or \r\n

I want to read a multi-line file in a bash script, using the file path from a variable, then merge the lines using a multi-char delimiter and save the result to another variable. I want to skip blank ...
Andreas's user avatar
  • 65
-2 votes
5 answers
141 views

how to cut the filename in way to contain only the first word before separator

I am trying to get the package name of the whl files the files are ls /python/*.whl /python/argparse-1.4.0-py2.py3-none-any.whl /python/Jinja2-2.11.2-py2.py3-none-any.whl /python/...
yael's user avatar
  • 13.9k

15 30 50 per page