Search Results

Search: Posts Made By: glev2005
31,093
Posted By Yoda
awk '{ for(i=0;i<=NF;i++) { if($i !~...
awk '{ for(i=0;i<=NF;i++) { if($i !~ /\/mnt\/svn/) s=s ? s OFS $i : $i } print s; s="" }' file
10,947
Posted By Corona688
Use -z for that. -z tests if a string is blank. ...
Use -z for that. -z tests if a string is blank.

if [ ! -z "$2" ]
then
echo "value $2"
else
echo "2 is blank"
fi

And don't leave out the quotes. [ ! -z ] is a syntax...
10,947
Posted By MadeInGermany
Such badness can be done. DATE=`date` #...
Such badness can be done.
DATE=`date`
# global variable stores a state of a function
gdone=0

func() {
echo asdf
if [ $gdone -eq 0 ]
then
gdone=1
mkdir mydir_${DATE}
fi
}
...
2,473
Posted By Corona688
I haven't seen that getopt actually makes shell...
I haven't seen that getopt actually makes shell code any simpler...

while [ "$#" -gt 0 ]
do
case "$1" in
-a) AVAR=ACTIVE
ASTR=$2
shift
...
2,473
Posted By Corona688
Actually, this already accounts for it. See the...
Actually, this already accounts for it. See the shift statements. They remove the first argument and move everything down. That's why I can just check $1 every loop.

i.e. if $1=a, $2=b, $3=c,...
2,493
Posted By Scrutinizer
It takes advantage of the greedy matching...
It takes advantage of the greedy matching characteristic of sed, which means that it will try to find the longest match possible.. So in this case the longest match to .*/ is /home/guru/temp/, so it...
1,570
Posted By radoulov
This is the one of the most frequently asked...
This is the one of the most frequently asked questions :)

awk '!_[$0]++' infile
2,502
Posted By vgersh99
nawk -f glev.awk qq='"' myFile glev.awk: {...
nawk -f glev.awk qq='"' myFile
glev.awk:

{
if (match($0, qq "[^" qq "]+" qq)) {
s=substr($0,RSTART,RLENGTH)
gsub("[:/]", "",s)
$0=substr($1,1,RSTART-1) s...
2,502
Posted By vgersh99
echo 'foo:"9781238274584-Ace of Spades/ The Poop"...
echo 'foo:"9781238274584-Ace of Spades/ The Poop" "Ace of Spades: The Poop" ...' | sed 's#"\([^"]*\)[:/]\([^"]*\)"#"\1\2"#1'
2,502
Posted By vgersh99
echo '"9781238274584-Ace of Spades: The Poop"...
echo '"9781238274584-Ace of Spades: The Poop" "Ace of Spades: The Poop" ...' | sed 's#[:/]##1'
2,502
Posted By 116@434
Try this: awk -F'"' '{gsub("[:/]","",$2);...
Try this:

awk -F'"' '{gsub("[:/]","",$2); print $0; }' myFile
16,354
Posted By ctsgnb
No, it expand before the file is removed rm abc...
No, it expand before the file is removed
rm abc ab*expand to
rm abc abc abd abe abf abg abhso the abc file appears twice
when trying to remove the second one, the file is not found because it...
3,924
Posted By radoulov
The _ is an array name. You can change it to...
The _ is an array name. You can change it to whatever valid identifier name you like - !my_awk_array[$0]++ would be the same.

! is a logical negation: NOT my_awk_array[$1]++

The expression...
3,605
Posted By methyl
Or using find properly: The "!" means "not". ...
Or using find properly: The "!" means "not".

# Just the names
find . -type f ! -name '*.jar' -print
# With directory listing
find . -type f ! -name '*.jar' -exec ls -lad {} \;
3,605
Posted By yinyuemi
try: find ./ -exec ls {} \; |grep -v .jpg
try:
find ./ -exec ls {} \; |grep -v .jpg
3,663
Posted By rdcwayx
awk -F, ' NR==FNR{a[$1]=$2;next} {for (i in...
awk -F, '
NR==FNR{a[$1]=$2;next}
{for (i in a) {if ($0~i) $2=$2 " " a[i]}}1
' FileA FS="\"" OFS="\"" FileB
1,498
Posted By vgersh99
nawk -F'"' '{gsub(" ","",$1);print "cd...
nawk -F'"' '{gsub(" ","",$1);print "cd /data/audiobooks/" $1; print "~/Desktop/mp3-to-m4b" OFS $1 "-" $2 OFS FS $2 FS OFS FS $4 FS OFS $5 OFS "n"}' myFile
2,367
Posted By yinyuemi
echo "TheWhisperers23Chapter 21 9781442305151 ...
echo "TheWhisperers23Chapter 21 9781442305151 \"WHISPERERS\" \"CONNOLLY, JOHN\" 2010" |sed 's/\(.*"\)\(.*\), \(.*\)\(".*\)/\1\L\3 "\u\3 \L\2 \u\2\4/' |awk '{$5=$7="";print $0}'...
2,367
Posted By Klashxx
A Perl : # cat file TheWhisperers23Chapter...
A Perl :

# cat file
TheWhisperers23Chapter 22 9781442305151 "WHISPERERS" "CONNOLLY, JOHN" 2010
TheWhisperers23Chapter 22 9781442305151 "WHISPERERS" "TORRES, FERNANDO" 2010

#...
1,639
Posted By Scrutinizer
time line-of-code See man time
time line-of-code
See man time
Showing results 1 to 20 of 20

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