All Questions
19
questions
2
votes
0
answers
400
views
Clear previous command output (not full screen)
Example
This is on the terminal screen:
user@host ~ % ls
dir1
dir2
dir3
user@host ~ % whoami
user
user@host ~ % date
Wed May 24 16:25:26 -03 2023
user@host ~ % [CURSOR IS HERE]
I'm trying to ...
0
votes
1
answer
525
views
Named capture groups from command line
I've come up with the following regular expression:
\[release(\s+(?<release_type>.*))?\]\n+(?<release_notes>.*)
The idea is to parse a commit message for several params:
[release minor]
...
1
vote
2
answers
336
views
how to run perl regex command remotely
I got this command that works perfectly on the remote server
perl -ne 'print "$1,$2,$3\n" if /^[^\[]*\[\K([^]]+)[^{]*{[^[]*\["\K([^"]+)(?:(?!SmsJob).)*SmsJob:\K([0-9a-f]+)/' /path/to/file.log
but ...
0
votes
2
answers
114
views
linux: how to capture the number/s from string
I use the following syntax in order to capture only the number from machine hostname
echo machineLinux05 | sed s'/\./ /g' | awk '{print $1}' | sed 's/[^0-9]//g'
05
But this way is not so elegant. ...
0
votes
1
answer
989
views
Executing Perl command from shell script not resulting into anything
I am trying to execute the below command from a shell script:
perl -pi -e 's/Ç/|/g' diff_new_old.dat
This command gets executed without any errors, but the execution doesn't do the intended ...
0
votes
1
answer
41
views
i need to pass a string of an output file to a variable so as i can use it globally all over my script [closed]
sample output
RETENTION_INTERVAL
------------------
10080
I need to pass the numeric value "10080" from the output file to a variable .The condition should validate value and ...
1
vote
4
answers
938
views
How to rename a lot of files in bash shell?
Sorry for the question. I searched the internet a lot, but couldn't find an answer which worked (though there were a lot of suggestions).
So, I want to rename A LOT of files. Writing all file names ...
0
votes
0
answers
77
views
open a new screen in linux, no access to perl local library
I added my perl local library to my shell startup script (.bashrc) and when I start a terminal in linux:
$ echo $PERL5LIB
/home/perl5/lib/perl5:/usr/share/vcftools/perl
BUT
when I open a new ...
1
vote
1
answer
718
views
Find number in string and replace it
I wrote C++ code and now I want to replace the number in a string by using shell scripts.
The part that needs to be replaced:
if (random<=90)
How I can change the 90 from a shell script?
I ...
0
votes
2
answers
833
views
sum numbers in different lines in shell
i have 8000 lines similar to this
<Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+924100.0ns" timeLastTxPacket="+199984927558.0ns" timeLastRxPacket="+199675473275.0ns" delaySum="+...
2
votes
3
answers
4k
views
How to extract characters between first and second underscores of filenames and count such files in Linux folder?
I would like to extract characters between first and second underscores of filenames in a folder and count such type of files present in it.
The folder contains files in a particular format such as:
...
0
votes
1
answer
293
views
shell or perl script to replace the double quotes with their unicodes
I am having two files names as a.html a.xml in a folder and in a.html file i have a tag
<div class="snippet abstract">
We present a new "model" for multiple-input-multiple-output (MIMO)...
7
votes
1
answer
4k
views
Shell script to find all types of files in a directory with their count
I want to write a shell script or alias to find the number of different types of files in a directory. For example, sample output of script should be:
*.h 20
*.c 40
*.cpp 10
Makefile 3
36
votes
5
answers
55k
views
How to cut a file to a given size under Linux?
I want to shrink a file's size by brute-force, that is, I don't care about the rest, I just want to cut the file, say by half, and discard the rest.
The first thing that comes to mind is Perl's ...
0
votes
1
answer
2k
views
script to convert GB to TB
I have (multiple) files like below list. Few of them has both the values in TB and couple of files in GB. Now if you clearly see the file output there are two rows with Total capacity and Capacity ...