Linked Questions
13 questions linked to/from Security implications of running perl -ne '...' *
77
votes
8
answers
56k
views
Who's got the other end of this unix socketpair?
I want to determine which process has the other end of a UNIX socket.
Specifically, I'm asking about one that was created with socketpair(), though the problem is the same for any UNIX socket.
I ...
29
votes
4
answers
2k
views
How to safely use gawk's -i option or @include directive?
Using gawk -i inplace some-awk-code some-file (or @include "inplace" within an awk script) to edit a file in-place (or any other extension) is a security vulnerability.
Why?
How do I work ...
24
votes
2
answers
64k
views
bash find: get directory of found file
I have a parent folder named "parent_folder" with a lot of subfolders, in these subfolders is a file named "foo.mp4".
I can find these files easily by doing this:
mymacbook:parent_folder username$ ...
2
votes
2
answers
3k
views
delete lines that sum to zero
I need to delete all lines in a file, if the values in all the columns are 0 (so if the sum of the row is 0).
My file is like this (13 columns and 60000 rows, tab delimited)
KO gene S10 S11 S12 ...
0
votes
2
answers
4k
views
What purpose does dot slash serve? [duplicate]
As I understand it:
./filename executes filename as a script.
./ indicates the current directory.
What purpose (if any) does the ./ serve if precedes a glob qualifier (filter):
qpdf --empty --pages ....
2
votes
3
answers
648
views
Move files to directory according to the content pattern matching
I would like to move files in existing directory files containing specific content to an existing or new directory and subdirectory by writing a script called fruit in ~/bin that moves them to dir/...
0
votes
4
answers
4k
views
Dynamically reference a file's name
In a single directory, I'd like to replace the first line of each file with the file's name. Each file has as the first line "TestRelation." I'd like to replace it with the file's name.
I know I can ...
1
vote
4
answers
3k
views
Replacing a character at a random position using sed?
I'm trying to replace a character in a file at a random position. My file looks something like:
aab
babab
abab
I'm trying to replace a random character for 'c'. So the output might look like:
...
0
votes
2
answers
727
views
How can you make the one-line version of Perl grep into an alias?
I found that we can use
perl -wnle "/RE/ and print"
such as
perl -wnle "/^.{0,80}$/ and print"
or
grep -ri someText * | perl -wnle "/^.{0,80}$/ and print"
to exclude lines longer than 80 characters....
2
votes
4
answers
302
views
Parse text file add semicolons before and after numbers; join all other words that are before/ between numbers with hyphens
I have a text file with accounts like:
Input Sample
Paid 100 15/02/2022 3000
recd 50 15/02/2022 nelur trip 3050
PAID 80 25/03/2022 Adjusted towards trip 3130
14 PAID 50 26/03/2022 Given to Nate Cash (...
1
vote
2
answers
163
views
String Length Always Returns 2 in ZSH Function
I'm trying to bowdlerize email addresses in a fixed length text file by generating a random string the same length as the input. I'm passing the string as a backreference in sed.
To simplify, this ...
0
votes
1
answer
170
views
Using Perl to modify specified lines of an ASCII file
Background:
(1) I have a data set of scientific notation:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.503832e-05, 1.433673e-05, 2.557402e-05,
3.081098e-05, 4.044465e-05, 2.480817e-05, 2.681778e-05, 1....
0
votes
2
answers
117
views
awk to wrap Unicode lines at 72 column
The following awk code wraps lines at the 72 column:
awk -v maxLen=72 '
{
out = sep = ""
for ( i=1; i<=NF; i++ ) {
nextOut = out sep $i
if ( ...