167 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
1
answer
83
views
How to grep multiple words from a remote file in a SSH command to a target server
I wanted to execute the below command. I have a file with server names.
for i in \`cat /tmp/srv_list\`; do ssh $i "uname -a; uptime; grep -E "warn|error|failed|issues" /var/log/...
1
vote
1
answer
120
views
How to split a long powershell -Command "Powershell code to execute" line in cmd so both cmd and Powershell is happy? [duplicate]
I am using the following code to start putty according to the current COM name:
powershell -Command "$COMPORT=(Get-WmiObject Win32_SerialPort | Select-Object Name, DeviceID | Where-Object { $_....
0
votes
1
answer
123
views
Moving elements of a python dictionary to another one under certain condition using less code
OK, so this is more a code "optimization" exercise.
I have to move all elements from a python dictionary to another, under certain condition, while emptying the source dict at the same time. ...
0
votes
0
answers
69
views
Bash one-liner with renice in an alias, ; and & not helping
I'm setting an alias for projectMSDL in bashrc. The arguments to tune it aren't the problem. It does work, but I want to add a renice to tune it a little more. I ultimately want to run two instances, ...
-5
votes
2
answers
102
views
Complex list comprehension - one liner [closed]
I attempted to create a one-liner to print out this ("the non-perfect list of safe characters for filenames, in most operating systems"):
$ python ./z.py
+,-.
0123456789
@...
0
votes
1
answer
117
views
Can I checkout an unfetched remote git branch, with a single command?
A very popular question here on SO is:
How do I check out a remote Git branch?
but the answers there either assume the branch-of-interest is already fetched, or suggest that we git fetch first.
My ...
0
votes
0
answers
56
views
I want to turn this command into an alias with stdin, is there a way to?
In the command below, I want to be able to make the regex pattern in the perl process an stdin instead, and turn that into an alias, and maybe the filename at
the end to, I use this line a lot to find ...
1
vote
1
answer
83
views
Optimize performance Euler problem 12 in a Julia oneliner
I recently started coding in Julia (coming from Python).
To practice my Julia skills, I started solving Euler problems.
Euler problem 12 (https://projecteuler.net/problem=12) is not so hard to solve.
...
0
votes
3
answers
84
views
In bash, how to one-line concatenate files into cin turned as argument to an executable?
In bash, how to one-line concatenate files into cin turned as argument to an executable?
Basically, I have this:
>> cat file.cpp
#include <iostream>
#include <string>
int main(){
...
0
votes
1
answer
80
views
shell or perl one liner to store tab separated values in two different variable
I have a tab-separated file like this:
test test2
test3 test4
I want to read each line, store the first field in $a and 2nd in $b using a shell or Perl one liner. Because then I need to ...
1
vote
2
answers
262
views
Tool for conversion of multi-lined Bash scripts to a single line
From my understanding, it is possible to convert any bash script into a single line by inserting semi-colons at the end of each line of code and removing the new-line.
Firstly - am I correct in this ...
0
votes
1
answer
27
views
How can I do a code in one line, that processes random data?
You measure the time dependence of a certain value 10 times by selecting 100 time values, as a result you get an array of 10x100. Simulate it with random values:
arr = np.random.random((100, 10))
...
0
votes
1
answer
95
views
perl one-liner to change : to / and / to : in single line
Is there a perl one-liner to change ":" to "/" and "/" to ":" in every line of a file.
for example:
fffc002/fffc002:9090
fffc003/fffc003:9090
fffc004/fffc004:...
0
votes
1
answer
624
views
Skip over numpy.linalg.LinAlg error : Singular matrix in a one liner
I have a dictionary whose values are matrices. I want to invert these matrices but some of them are singular, hence I get thrown the Singular matrix error when running the program. Here is a minimum ...
0
votes
1
answer
56
views
Sub Type Comparator One Liner Issue
Why do I need a temporary variable as personAgentComparator needed here and to call reversed() on that?
public class SubTypeComparatorIssue {
public void sortAgeFromOldToYoung(List<Person> ...