Search Results

Search: Posts Made By: Scrutinizer
167
Posted By Scrutinizer
Slightly more "traditional" way of doing this: ...
Slightly more "traditional" way of doing this:

for (( i=0; i<${#L1[@]}; i++ ))
do
printf "%s %s\n" "${L1[i]}" "${L2[i%${#L2[@]}]}"
done

or
lenL1=${#L1[@]} lenL2=${#L2[@]}
for (( i=0;...
597
Posted By Scrutinizer
Pertaining to post #1: Try: join -12 -22 -o...
Pertaining to post #1: Try:
join -12 -22 -o 1.1,2.1 <(xargs -n1 <file1) <(xargs -n1 <file2)
Forum: Shell Programming and Scripting 2 Weeks Ago
385
Posted By Scrutinizer
Hi, try double quotes: sed...
Hi, try double quotes:
sed "s/${TOKEN1}\(.*\)${TOKEN2}.*/\1/" "$INPUT1"
The curly braces for variable expansions are good practice within strings, for reasons of readability and also to prevent...
440
Posted By Scrutinizer
You would need to compare $5 and $6 to all the...
You would need to compare $5 and $6 to all the ranges in $2, $3 so you would need to put them in memory first, so a way to do it would be to read the inputfile twice, the first time to put $2, $3 in...
Forum: Shell Programming and Scripting 2 Weeks Ago
725
Posted By Scrutinizer
One could also use quotes: ...
One could also use quotes:
AnzahlUeberstunden="$(date -d "$JAHR-$MONAT-$TAG $ArbeitEnde" +%s) - $(date -d "$JAHR-$MONAT-$TAG $NormalesArbeitsEnde" +%s)"
AnzahlUeberstunden='AnzahlUeberstunden / 60'
Forum: Shell Programming and Scripting 3 Weeks Ago
725
Posted By Scrutinizer
Because it is a an arithmetic operation (you are...
Because it is a an arithmetic operation (you are trying to divide a number by 60)

Therefore you need an arithmetic expansion ( see: Shell command language: arithmetic expansions...
716
Posted By Scrutinizer
Hi Ravinder, As long as a mv operation is...
Hi Ravinder,

As long as a mv operation is performed on the same file system - as is the case here - that should not pose a problem, since mv then only manipulates directory data: A file name is...
716
Posted By Scrutinizer
Note: -n (no clobber) for the mv command is...
Note: -n (no clobber) for the mv command is non-standard extension to the POSIX standard. Alternatively, try using -i for interactive use (but some systems ignore -i when used in a non-interactive...
Forum: Shell Programming and Scripting 4 Weeks Ago
720
Posted By Scrutinizer
Hi, the reason that the script is so slow, is...
Hi, the reason that the script is so slow, is that it is firing off 12 different sub shells per line in the input file, so that is 12 million sub shells in total, which is quite costly.
Examples of...
656
Posted By Scrutinizer
Hi, try something like: count=$( cargo build...
Hi, try something like:
count=$( cargo build 2>&1 | grep -c 'error\[' )
Forum: Shell Programming and Scripting 4 Weeks Ago
823
Posted By Scrutinizer
Hi MadeInGermany, Can't you use: echo_e()...
Hi MadeInGermany,

Can't you use:
echo_e() {
printf "%b\n" "$*"
}

Instead?

The use of "$*" means that this only works as long as IFS is at the default:

$ IFS=,
$ echo -e "a\nb" c d...
Forum: Shell Programming and Scripting 4 Weeks Ago
1,334
Posted By Scrutinizer
It appears that it has been implemented in the...
It appears that it has been implemented in the system's regex engine, but that it does not work with globbing. On Linux, in bash 4 compare:
$ touch Miraré
$ for file in M*; do if [[ $file ==...
1,334
Posted By Scrutinizer
On Solaris 10, I tried the following, using the...
On Solaris 10, I tried the following, using the POSIX compliant utilities which are in /usr/xpg[46]/bin:

$ export PATH=/usr/xpg6/bin:/usr/xpg4/bin:$PATH
$ printf "%s\n" Estrés Miraré...
977
Posted By Scrutinizer
Hi, try: awk '/^[0-9]/{print x}1' file | ...
Hi, try:

awk '/^[0-9]/{print x}1' file |
awk '{$1=$1}1' RS= FS='\n' OFS=§ |
sort -rnk 5,5 |
tr § '\n'


Split the records with a blank line, using a digit on the first position as the...
977
Posted By Scrutinizer
@ravinder, yes POSIX sort does not have a -s...
@ravinder, yes POSIX sort does not have a -s option, see:
sort (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html)

but GNU sort and BSD sort do.
866
Posted By Scrutinizer
This command (if you are using GNU sed): sed...
This command (if you are using GNU sed):
sed 's/^1\|[0-9]*\_STATUS/STATUS/' outputOFF_00280456_2014_TEST.txt
Means replace either :
The digit "1" on a line that starts with that digit OR
zero or...
1,219
Posted By Scrutinizer
Ah so it is the other way around? The hostname is...
Ah so it is the other way around? The hostname is always lowercase, but the path may be uppercase?

Try something like:
cd $(ls -d "$(hostname)"* "$(hostname | tr '[[:lower:]]' '[[:upper:]]')"*...
931
Posted By Scrutinizer
Hi, try: awk 'NR==FNR{A[$1]=$2; next} {print...
Hi, try:
awk 'NR==FNR{A[$1]=$2; next} {print $1, $1 in A? A[$1]:0}' file2 file1
881
Posted By Scrutinizer
In for some golf :) ? awk '{$1=A[i=$1];...
In for some golf :) ?
awk '{$1=A[i=$1]; A[i]=$0} END{for(i in A) print i A[i]}' FS="\t" OFS="\t" A.txt
673
Posted By Scrutinizer
sed "s/[^ \t]*/'&'/" infile awk '$1=q $1 q'...
sed "s/[^ \t]*/'&'/" infile
awk '$1=q $1 q' q=\' infile
867
Posted By Scrutinizer
Try: awk '$2=="Total Sequences"{n=-3}...
Try:
awk '$2=="Total Sequences"{n=-3} ++n==0{print "$ts=" $2}' RS=\< FS=\> file
1,684
Posted By Scrutinizer
Hi, with sed you can try: sed...
Hi, with sed you can try:
sed 's|<td>\([0-9]\{1,\}\)</td>|<td><button onclick="reset(\1)">Reset</button>\1</td>|' file
You can add the leading tabs if you need them, but in the sample there were...
814
Posted By Scrutinizer
Hi, try: sort -t/ -k2,3r -k1,1rn -k4 file ...
Hi, try:
sort -t/ -k2,3r -k1,1rn -k4 file

120 /root/path2/part-00000-d3700305-428d-4b13-8161-42051f4ac5ed-c000.json
72 /root/path2/BishnuPrasadRout[5_0].doc
4 /root/path2/hello.c...
1,098
Posted By Scrutinizer
Try: awk ' NR==FNR { ...
Try:

awk '
NR==FNR { # When reading the first file (then NR is equal to FNR)
A[$1]=$0 # Store the first file...
860
Posted By Scrutinizer
Also try: awk -F= '/^>/{if(getline<f>0) $0=">"...
Also try:
awk -F= '/^>/{if(getline<f>0) $0=">" $2}1' f=list.txt gene1.fasta

or without the check:
awk -F= '/^>/{getline<f; $0=">" $2}1' f=list.txt gene1.fasta
Showing results 1 to 25 of 500

 

Featured Tech Videos

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