Tag Info

New answers tagged

3

It appears you're trying to use ttyS0 as a means to connect two processes. This won't work reliably since ttyS0 is the interface to a serial line (COM1: in Windows-speak). On the other hand, it might be that information is missing from your question. If you really do have a device on your serial port, please make that clear. What I believe you're looking ...


1

The man page of your shell will usually help. Lets take your first example. if [ $? -ne 0 ]; then On my system man ksh says: if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi The list following if is executed and, if it returns a zero exit sta‐ tus, the list following the first then is executed. Otherwise, ...


1

There is no problem to do thing with xargs myCommand | xargs -I{} sh -c 'echo -n {}\ ; cat /folder/{}/folder2/file' But more syntaxically right and much flexible do it with for loop: for genpath in $(myCommand) do echo -n $genpath\ cat /folder/$genpath/folder2/file done Or even through while loop while read genpath do echo -n $genpath\ ...


0

You can try to use command substitution with bracket list expansion: cat /folder/["$(myCommand)"]/folder2 Example with printf as a command: $ mkdir dir1 dir2 dir3 $ echo a > dir1/file $ echo b > dir2/file $ echo c > dir3/file $ cat ./dir["$(printf "%s\n" {1..3})"]/file a b c


0

You can use -I with xargs to replace a placeholder in your command: myCommand | xargs -I % cat /folder/%/folder2


0

Working code solution for anyone who just came here for a copy-paste based on wurtel's: #!/bin/bash for i in {01..84}; do #declare array to store files with same prefix declare -a files=() echo "Processing $i" for j in `ls $i*.csv`; do #add files with same prefix to array files=("${files[@]}" "$j") done #cat first ...


4

The format of the file is probably little-endian UTF-16. Some apps on Windows seem to default to this, and it causes a lot of porability problems. vi represents ASCII-Nul (numerically zero) valued bytes as '^@' (control-At). You can actually enter zero-valued bytes in vim with the control-shift-@ chord. grep must see the ACII-Nul bytes, rather than ...


0

This command list: echo -e "trapetz\nsimpson" | xargs -I fn sh -c "wc -c fn | sed 's/\(.*\) \(.*\)/\2: \1 chars/';cat -b -t fn" Produces this output trapetz: 73 chars 1 x = 0:0.0001:7pi 2 plot(x, sin(x).*cos(x)) 3 Area = trapz(x, sin(x).*cos(x)) simpson: 59 chars 1 f = inline(sin(x).*cos(x)); 2 Area2 = quad(f, 0, 7pi, 1e-16) ...


4

Yes, grep sw the ^@ characters. cat is printing the characters to the terminal, but they are characters you can't see. Just because you can't see the characters doesn't mean they aren't there. Your choice/preference, depending on which one works best for what you need. Remember, though, that vi has the possibility to change the file. ^@ is not a natural ...



Top 50 recent answers are included