Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a csv with 100 rows, i want shuffle all rows skipping the first 2, but i dont find how exclude the first 2 lines
Now it is like this:
shuf words.txt > shuffled_words.txt
Can somebody help me?
The shell lets you easily combine text and file manipulation commands using pipes.
sed 1,2d words.txt | shuf >shuffled_words.txt
There are many ways to skin this cat; tail -n +2 words.txt or awk 'FNR>2' words.txt are also common and idiomatic ways to remove the first two lines.
Or something like this:
( head -n 2 words.txt ; tail -n +2 words.txt|shuf ) > shuffled_words.txt
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 days ago.
This post was edited and submitted for review 6 days ago.
Improve this question
In a grep that i use to find some values in a log, i'm using
-exec grep -cHF "55=36" {} \; | grep -v ":0"
To show me values that are different to zero, so i get this output:
opt/route/file_1.log:7
I want to know how i can set a range of numbers to show me, for example if the grep finds only 7 matches no to show me anything but if it is more than 50 ( > 50), to show me the output.
I was told that maybe something like this could work?
grep -v ':[0-7]$' but it doesn't seem to work for me
Like this:
<INPUT> | tail -n+7
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I got the following line
2020-10-17 14:55:39,586 INFO [http-bio-exec-60] [] [D88E13F571A51598613FAA078A215326.server.host.com.:9991] [some.package.Class] TEST_STRING - RSI: 506B48ECADC4BE0CEBF7C7D33D036B67.server.host.com.:9991
I do grep "D88E13F571A51598613FAA078A215326" and got the line above. Is there a way to run a command after grep to check if D88E13F571A51598613FAA078A215326 and 506B48ECADC4BE0CEBF7C7D33D036B67 are equal?
Thanks.
This will work if you already know the first pattern:
PATTERN=D88E13F571A51598613FAA078A215326
grep "\[$PATTERN.*RSI: $PATTERN" input_file
I got the following line, that's not a good way to start here:
Your line contains quite some information, and as mentioned in the comments, you might parse it using Perl or awk or any other tool, but I would advise otherwise: how do you get this line (I guess it's an output of some process)? You might ask the author of that other process to alter the output in such a way that it's easier for you do parse it and do the comparison you're aiming for.
Pipe grep output into this Perl one-liner, which splits the line on non-word characters and prints it if fields 13 and 23 are identical as strings:
echo '2020-10-17 14:55:39,586 INFO [http-bio-exec-60] [] [D88E13F571A51598613FAA078A215326.server.host.com.:9991] [some.package.Class] TEST_STRING - RSI: 506B48ECADC4BE0CEBF7C7D33D036B67.server.host.com.:9991' | \
grep 'D88E13F571A51598613FAA078A215326' | \
perl -F'/\W+/' -lane 'print if $F[12] eq $F[22];'
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm wondering if I can merge multiple ls results.
I have to combine 3 ls -l results; two directories have to list only directories in them, and the other lists symbolic links only.
The merged list'll finally be sorted by name or by date.
I did it by java code but I want to do it by single Linux command line if possible.
Thanks
I think you are better of doing this in find, but using ls -l to get out your file info for sorting by sort. Like:
find /path/dir1 /path/dir2 /path/dir3 -maxdepth 1 -exec ls -l --full-time {} + | sort -k 6,7
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to make a command where I list that directories which are contains only two letters.
How can I do it?
? is a wildcard for one character. So, the following should work:
ls -d ??/
The -d prevents ls from listing the contents of the directories, the final / excludes files.
ls -F | grep -o "^.\{2\}/$"
ls -F lists content by file system object type
| grep -o filters out anything that doesn't match the regex expression ^.\{2\}/$ which basically says 'match only folders with 2 characters in their name'
ls */ | awk 'length($0) < 3'
Note that this does not match hidden directories. choroba's answer is better, because it is usually a bad idea to parse the output of ls, but I like this for its readability.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I need help with comparison of two files and get the positions in third file, both files will have the same fields but the order will be unsorted in 2nd file, third file will give the line number where the data is found.
eg. file1.txt
A
B
C
D
file2.txt
B
D
A
C
outputfileposition.txt
3
1
4
2
Any help appreciated, thanks in advance
In awk
awk 'FNR==NR{a[$0]=FNR;next}{print a[$0] > "outputfileposition.txt"}' file{2,1}.txt
This will do the trick :
while read line
do
grep -n $line file2.txt | grep -o ^[0-9]* >> outputfileposition.txt
done < file1.txt