Search Results

Search: Posts Made By: tokland
7,177
Posted By tokland
Very nice. Named pipes are not so cool, but now...
Very nice. Named pipes are not so cool, but now we have full control over the job (I guess that's not so easy with process substitution)

Thanks Alister!
7,177
Posted By tokland
Hi! Thanks, those are good solutions....
Hi!



Thanks, those are good solutions. However, the grep in my code was just an example, let's imagine you cannot change how the stream is generated:

stream_generator | head -n1

By the...
7,177
Posted By tokland
Problem with pipes on infinite streams
Here is an example code that shows the issue I have:


#!/bin/bash
counter() {
seq 1000 | while read NUM; do
echo $NUM
echo "debug: $NUM" >&2
sleep 0.1 # slow it down so we...
6,479
Posted By tokland
Script to run it N times. You get the idea for...
Script to run it N times. You get the idea for the 4/20 times scenario.


#!/bin/bash
TIMES=$1
cd "$SWDIR/util"
for((i=0; i < TIMES; i++)); do
./swadm add_process 1 BG Y
done


$...
3,221
Posted By tokland
Absolutely. Actually, I have this tr...
Absolutely.

Actually, I have this tr command aliased (lineto0) but I didn't remember it.
3,221
Posted By tokland
The -d option is used to set the delimiter...
The -d option is used to set the delimiter between fields. If your xargs does not have this option, you can omit it; it will work fine except for filenames with spaces
4,500
Posted By tokland
Yes, (tacit) initial assumption was that we don't...
Yes, (tacit) initial assumption was that we don't have newlines in our data domain. That should cover most scenarios (why UNIX allowed newlines in filenames, I'll never know).
3,221
Posted By tokland
You are connecting to the server for each file,...
You are connecting to the server for each file, this is slooooow; you should connect only one time. There are lots of ways of doing it, that's one:

ssh server ls remotedir | ( cd localdir && xargs...
4,500
Posted By tokland
Hey, that's a good idea, use cat to join multiple...
Hey, that's a good idea, use cat to join multiple argument sources.



That's right, xargs works perfectly when inserting arguments at the end of the command.



That would work in my...
4,500
Posted By tokland
Unless really necessary, I think it's better to...
Unless really necessary, I think it's better to avoid "eval" approaches, it can get tricky (i.e. you have to worry about escaping quotes).
4,500
Posted By tokland
Xargs and
Hello there,

Let me show you a simple example of what I am trying to achieve:

1) I have an input text file with some lines:

1 a
2 b
3 c

2) And I want to run a command with these lines...
5,126
Posted By tokland
Strange behaviour with "set -e" and functions
Hi,

This seems to be a recurrent problem on mailing lists and bug reports, but I've been unable to find a solution. Let's imagine we have this bash script:

#!/bin/bash
set -e

fun() {
...
1,916
Posted By tokland
Thanks for your reply. I see two problems,...
Thanks for your reply. I see two problems, though:

- You build by hand the pairs to rename, and this should be automatic. That's why I use paste, to simulate a zip function found in some scripting...
1,916
Posted By tokland
Renaming a bunch of files
This is possibly a FAQ, but I was unable to find an answer: let's say you have two files named "hello.txt" and "goodbye.txt" and you want them to be "hi.txt" and "seeyou.txt". The typical regular...
2,478
Posted By tokland
Yes, I'm aware of this, it was just an example. ...
Yes, I'm aware of this, it was just an example.



Certaintly. A pure bash solution (less versatile as it does not use xargs) I though was as simple as:

#!/bin/sh
COMMAND=$1
while read LINE;...
2,478
Posted By tokland
Pipe filtering
Hi,

The thing is that sometimes I need to filter an arbitrary output given a condition (think on the "filter" function present on some programming languages) from the shell (I use sh/bash). I...
Showing results 1 to 16 of 16

 
All times are GMT -4. The time now is 02:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy