Search Results

Search: Posts Made By: nnani
1,268
Posted By MR.bean
Like that? bash-3.2$ awk 'BEGIN{x=1}...
Like that?


bash-3.2$ awk 'BEGIN{x=1} /DEFINE SCHEMA/,/\)\;/ {if (NF==2) { $1="t"x" as filler"; print; x++ }}' filename
t1 as filler VARCHAR(10)
1,268
Posted By krishmaths
awk '{print "t"++i" as filler VARCHAR"}'...
awk '{print "t"++i" as filler VARCHAR"}' extract_file
17,784
Posted By krishmaths
awk solution
Using awk


awk '{print substr($0,length($0)-7)}' filename
17,784
Posted By Scrutinizer
Try: for i in *.tpt.ctl do ...
Try:
for i in *.tpt.ctl
do
var=${i%.tpt.ctl}
printf "%s\n" "$var"
done
17,784
Posted By Subbeh
Or using sed: sed 's/\(.*\).\{8\}$/\1/' file
Or using sed:

sed 's/\(.*\).\{8\}$/\1/' file
17,784
Posted By Jotne
@krishmaths Simpler approach awk -F....
@krishmaths
Simpler approach
awk -F. '{print $1}'

But why do it complicate, when we can do it the Scrutinizer way :)
17,784
Posted By MR.bean
echo abc.tpt.ctl | rev | cut -c 9- | rev abc ...
echo abc.tpt.ctl | rev | cut -c 9- | rev
abc

bash-3.2$ cat x
abc.tpt.ctl
bdc.tpt.ctl
cdw.tpt.ctl
bash-3.2$ cat x | rev | cut -c 9- | rev
abc
bdc
cdw
4,063
Posted By Jotne
Having real life data helps allot, why did you...
Having real life data helps allot, why did you not post it before :(
Now script only looks for end ) after pattern and ( is found.

awk '/APPLY/ {t=1} f && /\)/{exit} f; /\(/ && t {f=1}' file
...
4,063
Posted By krishmaths
@Jotne, Thanks for noting but my solution is not...
@Jotne, Thanks for noting but my solution is not generic and applies to the input data posted in this thread. I hope we both have given enough directions now :)
1,809
Posted By balajesuri
If you read from a file and write to it at the...
If you read from a file and write to it at the same time, all you get is a corrupted file.
sed has options for in-file editing --> the -i switch

sed -i.bak 's/bteq/tpt/g' filelist.txt

Now you...
1,876
Posted By krishmaths
awk '!(NR%2){$(NF+1)=";"}1' filename
awk '!(NR%2){$(NF+1)=";"}1' filename
1,876
Posted By ahamed101
awk '!(NR%2){$NF=$NF";"}1' infile ...
awk '!(NR%2){$NF=$NF";"}1' infile

--ahamed
1,123
Posted By pamu
Just check how many lines of your message has...
Just check how many lines of your message has header files.

Assume it first two lines are header file here.. use

"psql -c "\dt" | awk 'NR>2{print$3}'"
1,123
Posted By RudiC
From what we can see in the desired output, it...
From what we can see in the desired output, it should start with line 4, so pamu's proposal should be slightly modified to using NR>3.
1,465
Posted By Scrutinizer
I think that if you experiment a little with the...
I think that if you experiment a little with the printf statements you should be able to do this yourself. What have you tried so far?
Showing results 1 to 15 of 15

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