Search Results

Search: Posts Made By: yunccll
6,019
Posted By yunccll
why not use 'sort'? 'sort -r inputfile'
why not use 'sort'?

'sort -r inputfile'
5,711
Posted By yunccll
#!/bin/sh arr=(1 2 3 4) len=${#arr[@]} ...
#!/bin/sh

arr=(1 2 3 4)

len=${#arr[@]}

for(( i=1; i < $len; i++))
do
if [ ${arr[$i]} -eq 2 ] ; then
echo "exec some statement"
fi
done


.Aaron
2,679
Posted By yunccll
i think may be use set qu=($(condor_q|tail -1))...
i think may be use
set qu=($(condor_q|tail -1))

i test the statement in bash:
$ ls
a.sh hsperfdata_root https-admserv-9d93b4d6

$ arr=( $(ls))
$ echo ${#arr[@]}
3...
6,940
Posted By yunccll
u can try this: lame $src $dst && rm -frv...
u can try this:

lame $src $dst && rm -frv $src || echo "$src encoding failed"

when lame $src $dst return zero if lame encoding sucess.
2,302
Posted By yunccll
len= size of array for i in $len do #Create...
len= size of array
for i in $len
do
#Create a destination directory
ssh -q ${store_username[$d]}@${store_host_name[$c]} mkdir temp
#scp files to host
scp -r /root/temp...
3,765
Posted By yunccll
Output="" for(( i = 0; i< ${#HBA_WWN[@]}; i++))...
Output=""
for(( i = 0; i< ${#HBA_WWN[@]}; i++))
do
Output=$Output"HBA at ${HBA_WWN[$i]} is ${HBA_STA[$i]} ;;"
done
echo $Output


.Aaron
9,786
Posted By yunccll
$ cat file1 Switch not possible Error code 1234...
$ cat file1
Switch not possible Error code 1234
Process number 678

Log not available Error code 567
Process number 874

Log not available Error code 333
Process number 34

Log not...
1,174
Posted By yunccll
read str < <(cat file1 | tr "\n" " ") echo $str...
read str < <(cat file1 | tr "\n" " ")
echo $str


cat file1 | tr "\n" " " replace the "\n" to space,

read str < <(cmd) read the cmd 's stdout in the string str
8,288
Posted By yunccll
arr[$0]++, and if($0 in arr) u maybe use...
arr[$0]++, and if($0 in arr)
u maybe use this:
arr[$NF]++ and if($NR in arr)

The last one parameter of `ls -l ` is file name.

$0 has much info about every file in linux.
2,542
Posted By yunccll
According to your description above. I write down...
According to your description above. I write down a script as follow.
Wish to help you!

Assume there is a space between [Date: and 2008-05-16]
>cat infile
unixytreqasadddd <unix_unix@unix.com>...
2,840
Posted By yunccll
using awk (linux + bash): awk ' BEGIN {RS =...
using awk (linux + bash):

awk ' BEGIN {RS = ""; FS = "(\n)| ( )"} # set the record separator as ""

# save the first file name and 4th field of it in an array
NR == FNR { ...
1,499
Posted By yunccll
you can use the "rsync" to backup your files, if...
you can use the "rsync" to backup your files, if there is the tool in your system.

e.g.
rsync source/*.c dest/

more detail in man rsync

regards
.Aaron
3,473
Posted By yunccll
try this code: #! /bin/bash' i=0; ...
try this code:

#! /bin/bash'

i=0;

for file in `ls`
do
let i++
awk '{
if( $0 !~[:space:]?$/)
suffix = " '" $i "'"
else
...
3,534
Posted By yunccll
dirname or substring removal operator ${%} ...
dirname or substring removal operator ${%}

str="/home/psv/file/test.ksh"

echo `dirname $str`/
echo "${str%/*}/"
2,881
Posted By yunccll
assume that there is only a single line in fileB!...
assume that there is only a single line in fileB!
using awk :

awk 'NR == FNR {var=$0}
NR != FNR {
if(FNR > 1) $3 = "+"$3;
print $3 "*" var
}' FS="(+)|(-)"...
12,427
Posted By yunccll
if you want to do this job with script, you can...
if you want to do this job with script, you can try code as follow:

#!/bin/bash

INFILE=output.txt

#replace the double quote with space
LIST=$(sed -e 's/\"/ /g' $INFILE)

zip archive.zip...
4,519
Posted By yunccll
awk 'BEGIN{FS="( )|(,)"}...
awk 'BEGIN{FS="( )|(,)"} /^Name/{n=$NF}/^Address/{split($0, arr, "\""); a=$2" \"" arr[2]"\""}/^City/{print n,a,$NF}' data
maybe, This is what you want!

.Aaron
4,519
Posted By yunccll
FS means Field Separator , using FS="( )|(,)"...
FS means Field Separator , using FS="( )|(,)" means current FS is the space or ','
if you use the statement, the result is
lastname1 111 Hilversum
lastname2 222 Bussum
lastname3 333 Amsterdam
...
3,608
Posted By yunccll
>cat x.txt z 11 az x 12 ax y 13 ay >cat...
>cat x.txt
z 11 az
x 12 ax
y 13 ay
>cat y.txt
ay TT
ax NN
>sort x.txt > sx.tmp && sort y.txt > sy.tmp && join -1 3 -2 1 -o "1.1 1.2 1.3 2.2" sx.tmp sy.tmp | sort -r && rm -fr *.tmp
y 13 ay TT...
4,226
Posted By yunccll
oh,sorry, I forgot the "max =cur", when I input...
oh,sorry, I forgot the "max =cur", when I input my code into the reply!

.Aaron
4,226
Posted By yunccll
try this code: #!/bin/bash #constant ...
try this code:
#!/bin/bash

#constant
INFILE="max.txt"

#core script
awk ' BEGIN { OFS=FS=":"; cur=max=0; seen=""}
{
cur = length($1)
if(cur > max ){
...
2,166
Posted By yunccll
try this code(bash): #!/bin/bash ...
try this code(bash):

#!/bin/bash

#constants
CNT=10
SOURCE="file1.txt"
RESULT="file2.txt"

#copy first field to file2.txt from file1.txt
cat $SOURCE > $RESULT
printf "\n" > $RESULT
...
3,920
Posted By yunccll
try this: case ${FileName##*.} in ...
try this:

case ${FileName##*.} in
txt|dat|csv)
mv $SourceFileDir/$FileName $TargetFileDir/ ;;
esac

(Bash)
Showing results 1 to 23 of 23

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