Quantcast
Channel: User ozzy - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 31 View Live

Comment by ozzy on how to capture details from nc

@yael I didn’t downvote your question. Why do you assume it was me?

View Article



Comment by ozzy on Using pv with md5sum

Since you are not feeding 4Gb of data down the pipe, but just the output of md5sum for a plurality of files, changing the -s 4g option such that it reflects an estimate of the size of md5sum's output,...

View Article

Comment by ozzy on Using pv with md5sum

@frostschutz You are undeniably right :-) This is a nicer, cleaner solution.

View Article

Comment by ozzy on How can i remove duplicate files that contain 2 matching...

@jonnyb Can you insert an "echo $k" above the if-statement (below the k-assignment) to see what the bad key is? I don't have a bad key for the files you showed in your post.

View Article

Comment by ozzy on Identify and email results

@BradJenkins That sounds like doing scriptable work. What is the problem with the script-solution? Running a local MTA or smth else?

View Article


Comment by ozzy on Removing leading zero in pipe delimiter file using awk

@Mouli This is one of the beauties of awk: an entire record (here: a line) is referred to as $0; it is composed of the different fields into which it is automatically split based on the input field...

View Article

Comment by ozzy on Run script in background using `&` or `()&`?

Possible duplicate of: putting subshell in background vs putting command in background

View Article

Answer by ozzy for Convert file contents to lower case

Further to MvG's answer, you could also use Perl 6: perl6 -pe .=lc temp Here $_ is implicit, and you don't need the single quotes to protect it from expansion by the shell ($_ being a special Bash...

View Article


Answer by ozzy for Getting bash: mvn: command not found

It seems you downloaded a source archive (see the "-src" in the filename) that does not contain the binary you are trying to run. Try downloading and unpacking a binary archive (with "-bin" in the...

View Article


Answer by ozzy for Is there a character as `delim` of `read`, so that `read`...

The answer is generally "no", simply because - as a general rule - there is no actual character in a file that conclusively marks the end of a file. You are probably well advised to try a different...

View Article

Answer by ozzy for Unix command to search with a string of 6 numbers for any...

Assuming that you have a file named file that contains lines with mutually different whitespace-separated numbers, and you have a set of 6 numbers - e.g. 38, 39, 40, 41, 42, 43 - that you want to...

View Article

Answer by ozzy for How to extract duplicate numbers from a log file?

You could use: grep -oP 'SubscriberNumber=\K(\d+)' logfile | sort -n | uniq -cd grep -oP 'SubscriberNumber=\K(\d+)' logfile isolates all individual SubscriberNumbers from your logfile; sort -n sorts...

View Article

Answer by ozzy for want to Rename Images In Bulk in Linux

In Bash, the solution could look like this: #!/bin/bash shopt -s extglob for fn_old in *.jpg; do i=0 fn_new=${fn_old##+([-0-9])} # strip leading number sequence in basename...

View Article


Answer by ozzy for how to find & replace a file path listed in a file

You could use: sed -i -E -e 's/(\/.*\/)(.*\.idt)/\2/' file_list This performs an in-place (-i) replacement of all /..../filename.idt filepaths with filename.idt ("all" as in: the first occurrence on...

View Article

Answer by ozzy for Awk - convert time value to decimal value

How about this? awk -F: '{printf "%.1f", ($1*60+$2)/60}' <<< 1:30

View Article


Answer by ozzy for how can I merge two text files together

If file1 is your first text file, and file2 is your second text file, this should work in Bash: join -a 1 <(sort -k1,1 file2) <(sed -E -e 's/([^\s])\(/\1 (/' file1 | sort -k1,1) Join is called...

View Article

Answer by ozzy for Run parallel command and redirect the output to files with...

Well, this is a somewhat over-engineered Bash-solution, but it works and hopefully clarifies the use of the parallel command: function xx(){ curl "https://jsonplaceholder.typicode.com/todos/$1" >...

View Article


Answer by ozzy for Understanding why hostname -i returns strange IP address

Unlike the hostname -I command, which just lists all configured IP addresses on all network interfaces, the hostname -i command performs name resolution (see the hostname man page). Since your newly...

View Article

Answer by ozzy for About ||||| (pipe or vertical bars) In yad --form --button

I cannot reproduce the situation you describe entirely, but I think you need to ask yourself what you want yad to do when a button is pressed, or, more specifically, how yad should communicate any user...

View Article

Answer by ozzy for Getting the last sentence of a running program from...

This should work: grep -m1 -oP '(\d{1,3}\.?){4}:\d{1,5}' <( your-qemu-command 2>&1 ) <( your-qemu-command 2>&1 ) is a process substitution that launches qemu with stdout/stderr...

View Article

Answer by ozzy for Write shell script to analysis log file

In an unpolished version, a Bash-script could look like this, assuming that your data is contained in datafile: #!/bin/bash printf "IPs where status is fail:\n" grep -z -oP 'IP=\K.*\n(?=STATUS=FAIL)'...

View Article


Answer by ozzy for Exit shell script containing indefinitely running java...

The question is a bit puzzling to me, not in the least because of the pipe (to tee) that you apparently wish to use. To maintain this functionality, you could use the following script: #!/bin/ksh tee...

View Article


Answer by ozzy for Usage of nc with timeouts in ms

I don't think it is possible with nc alone. But you can additionally use the timeout tool (GNU coreutils package) which allows you to run a command with a timelimit specified as a floating point...

View Article

Answer by ozzy for wget image problem for daily wallpaper script

Your script needs a bit of a makeover. The two lines following the #Set image url, name and location line are broken for various reasons (e.g. incorrect grep syntax, incorrect assignment). In addition,...

View Article

Answer by ozzy for How to grep a line who has execution time greater than X

Assuming that the lines continue after "Lambda", as suggested by the OP, this command should work: gawk 'match($0, /execution\stime:([0-9]+)s/, a) && a[1] > 10 { print $0 }' logfile with...

View Article


Answer by ozzy for Can't run parallel zgrep with regex

If you are using the parallel command from the moreutils package, your command could be simplified like this: parallel zgrep -e "\(text1\|text2\).*Exception" -- my.log*.gz This will run parallel...

View Article

Answer by ozzy for How to make symlink executable?

Bash will find an executable specified by its bare filename (i.e. without preceding path elements) only if it is on its search path, which is stored in the PATH variable. The current directory is not...

View Article

Answer by ozzy for Find and copy with exec not working

Your command appears to have two issues, the first of which may not matter much in your case, but is nevertheless worth pointing out: (i) it is not generic in the sense that it will not be able to...

View Article

Answer by ozzy for command line tool to download complete podcast from rss feed

I'm not really familiar with rss feeds or the format that they come in. Neither do I see, using newsbeuter for instance, the close to 200 episodes that you say are present in the feed (I see only 10...

View Article



Answer by ozzy for How to sort a file with multiple delimiters?

You could use this: awk 'NR<=4 {print $0; next } { print $0 | "sort -k6,6 -t\\|" }' listing.txt It runs awk on listing.txt; instead you could pipe the data into awk (leaving out the listing.txt at...

View Article

Answer by ozzy for Replace lines in multiple files matching a pattern with...

With GNU awk (i.e. gawk) you could do: gawk -i inplace '/mock/ { getline < "mock.txt" } 1' test{1..3}.txt Like sed, gawk offers inplace editing. The above command looks for the regex-pattern mock,...

View Article
Browsing latest articles
Browse All 31 View Live




Latest Images