Search Results

Search: Posts Made By: calredd
Forum: Programming 05-11-2017
2,814
Posted By disedorgue
Hi, Example (in red for you) : with T As ...
Hi,
Example (in red for you) :
with T As
(select 123 as c1, 'NY,NJ,CA' as c2 from dual
union
select 124 as c1, 'NY,PA,' as c2 from dual)
SELECT DISTINCT C1, regexp_substr(C2,'[^,]+', 1,...
3,178
Posted By RudiC
How about redirection? Try < filex tee -a...
How about redirection? Try < filex tee -a execution.log
bash: filex: No such file or directory
echo $?
1
Alternatively, if you're using bash, there's the PIPESTATUS array.
3,178
Posted By Aia
I understood your dilemma. That's why I gave that...
I understood your dilemma. That's why I gave that snippet. It is not only tee but for any chained commands: $? will report about the last command executed.

Is the following not your intention?
if...
3,178
Posted By Aia
There is a flag -s to test if a file exist and...
There is a flag -s to test if a file exist and its content is greater than zero.

Something like...
if [[ -s incoming.dat ]]; then
echo "File is not empty, now I can do something with it"
fi
2,343
Posted By RavinderSingh13
Hello calredd, Following may help you in...
Hello calredd,

Following may help you in same.

FLAG=file_name
ls -l test* | awk -vflag="$FLAG" '{print flag,$9}'
EDIT:
Hello Sea,

There is no need of using ls -ltr, in spite ls -l can...
2,343
Posted By sea
Please use code tags, not icode tags for console...
Please use code tags, not icode tags for console output and commands.

Try either one:
FLAG=file_name
ls -ltr test* | awk -v FLAG=$FLAG '{print FLAG,$9}'
ls -ltr test* | awk -v FLAG=$FLAG...
5,124
Posted By Don Cragun
In case the database might be switched to use...
In case the database might be switched to use expected spaces in names (such as NEW YORK instead of underscores (as in NEW_YORK), you might want to change:
FNR==1 {gsub (" ", "", KEY)
...
5,124
Posted By RudiC
Tryawk -F, ' FNR==1 {for (n=1;...
Tryawk -F, '
FNR==1 {for (n=1; n<=NF; n++) {if ($n==COL) KEYCOL=n}
next
}
$1==KEY {print $KEYCOL}
' KEY=CHICAGO COL=COUNTY file
COOKIn...
5,124
Posted By Don Cragun
I asked "How are the keys supplied to your...
I asked "How are the keys supplied to your script?" You responded "A value from first column and a column name
Ex: NEWARK & STATE, SEATTLE & COUNTRY, NEWARK & COUNTY"
That response is an answer to...
2,586
Posted By Don Cragun
So, try: awk 'NR>a+b{print (b>0 ? A[NR%b] :...
So, try:
awk 'NR>a+b{print (b>0 ? A[NR%b] : $0)} b>0{A[NR%b]=$0}' a=2 b=1 file
2,586
Posted By Scrutinizer
Try: awk 'NR>a+b{print A[NR%b]} {A[NR%b]=$0}'...
Try:
awk 'NR>a+b{print A[NR%b]} {A[NR%b]=$0}' a=2 b=1 file
969
Posted By Scrutinizer
egrep (or grep -E nowadays) takes an extended...
egrep (or grep -E nowadays) takes an extended regular expression, not unix pattern matching and it is best to quote the expression to avoid interference from the shell.
So instead try:
egrep...
2,001
Posted By Chirel
Hi cat list.txt ^New$ ^Old$ cat...
Hi

cat list.txt
^New$
^Old$
cat data.txt

New
New York
NewYork
DC
LA
Chicago
Dallas
Using the command now

$ grep -f list.txt data.txt
New
$
2,753
Posted By 47shailesh
I agree with Corona, and for Solaris use this...
I agree with Corona, and for Solaris use this insteadtail -$(sort -u -t"|" -k1,1 infile | wc -l) infileor /usr/xpg4/bin/tail -n $(sort -u -t"|" -k1,1 infile | wc -l) infileI would recommend...
2,753
Posted By Corona688
No reason I know of that tail -$n shouldn't work...
No reason I know of that tail -$n shouldn't work in sunos. That's processed before tail is run, so it really shouldn't notice any difference. Again, check the contents of $n to make sure there's no...
2,753
Posted By Scrutinizer
Try: awk -F \| 'NR==1{s=$1} s==$1{p=$0;next}...
Try:
awk -F \| 'NR==1{s=$1} s==$1{p=$0;next} {p=p RS $0} END{print p}' infile

On Solaris use /usr/xpg4/bin/awk instead of awk

DC | 18161621
LA | 17993534
NY | 18161621

DC | 18161621
LA |...
2,753
Posted By 47shailesh
one way can be: tail -n $(sort -u -t"|" -k1,1...
one way can be:
tail -n $(sort -u -t"|" -k1,1 infile | wc -l) infile
1,860
Posted By Scrutinizer
Try: grep -f state_names.lookup state_data.txt
Try:
grep -f state_names.lookup state_data.txt
1,598
Posted By shamrock
Redirect output of wc to test.err instead of the...
Redirect output of wc to test.err instead of the awk part...
export LINE_COUNT=`wc -l test.dat 2>test.err | awk '{print $1}'`
1,598
Posted By Corona688
Standard error doesn't pass through pipes. It...
Standard error doesn't pass through pipes. It goes directly to the terminal. So redirecting the last command only redirects errors the last program prints.

command 2> errlog | command2 |...
Showing results 1 to 20 of 20

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