awk condition for 30th column of a line is not working
up vote
-1
down vote
favorite
My Input file looks like below,
1,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,,kapeta,,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,C
2,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,20181006T11:57:13+0100,,vsuser,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,H
1,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,,enrruac,,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,C
4,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,20181007T22:25:13+0100,,vsuser,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,H
i want to print only the line that are starting with '1' and ends with 'C', so i am trying with below command,
awk -F, '$1=='1' && $31=='C'{print $0}' input_file.txt
but i am not getting any output.
awk syntax quotes nawk
add a comment |
up vote
-1
down vote
favorite
My Input file looks like below,
1,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,,kapeta,,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,C
2,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,20181006T11:57:13+0100,,vsuser,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,H
1,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,,enrruac,,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,C
4,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,20181007T22:25:13+0100,,vsuser,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,H
i want to print only the line that are starting with '1' and ends with 'C', so i am trying with below command,
awk -F, '$1=='1' && $31=='C'{print $0}' input_file.txt
but i am not getting any output.
awk syntax quotes nawk
2
With a regex:awk '/^1.*C$/' file
orawk '/^1,.*,C$/' file
– Cyrus
2 days ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
My Input file looks like below,
1,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,,kapeta,,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,C
2,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,20181006T11:57:13+0100,,vsuser,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,H
1,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,,enrruac,,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,C
4,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,20181007T22:25:13+0100,,vsuser,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,H
i want to print only the line that are starting with '1' and ends with 'C', so i am trying with below command,
awk -F, '$1=='1' && $31=='C'{print $0}' input_file.txt
but i am not getting any output.
awk syntax quotes nawk
My Input file looks like below,
1,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,,kapeta,,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,C
2,,B4,3000,Rushab,UNI,20130919T22:45:05+0100,20190930T23:59:59+0100,20181006T11:57:13+0100,,vsuser,6741948090816,2285917436,971078887,1283538808965528,20181102_20001,,,,,,,,,,,,,,,H
1,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,,enrruac,,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,C
4,,F1,100000,RAWBANK,UNI,20180416T15:25:00+0100,20190416T23:59:59+0100,20181007T22:25:13+0100,,vsuser,7522609506635,3101315044,998445487,1290161608965816,20181102_20001,,,,,,,,,,,,,,,H
i want to print only the line that are starting with '1' and ends with 'C', so i am trying with below command,
awk -F, '$1=='1' && $31=='C'{print $0}' input_file.txt
but i am not getting any output.
awk syntax quotes nawk
awk syntax quotes nawk
edited 2 days ago
Cyrus
44.1k43375
44.1k43375
asked 2 days ago
ramki_ramakrishnan
41117
41117
2
With a regex:awk '/^1.*C$/' file
orawk '/^1,.*,C$/' file
– Cyrus
2 days ago
add a comment |
2
With a regex:awk '/^1.*C$/' file
orawk '/^1,.*,C$/' file
– Cyrus
2 days ago
2
2
With a regex:
awk '/^1.*C$/' file
or awk '/^1,.*,C$/' file
– Cyrus
2 days ago
With a regex:
awk '/^1.*C$/' file
or awk '/^1,.*,C$/' file
– Cyrus
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
Use double quotes:
awk -F, '$1=="1" && $31=="C"{print $0}' file
or
awk -F, '$1=="1" && $31=="C"' file
Note that1
doesn't require quotes.
– karakfa
2 days ago
add a comment |
up vote
1
down vote
As other users suggested, this can be done using a simple regex. So you can use sed as well as awk
sed '/^1,.*,C$/!d' file
1
If you don't add the delimiters there will be false matches. For example.11,....,NotC
will match as well./^1,.*,C$/!d
should fix this.
– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Use double quotes:
awk -F, '$1=="1" && $31=="C"{print $0}' file
or
awk -F, '$1=="1" && $31=="C"' file
Note that1
doesn't require quotes.
– karakfa
2 days ago
add a comment |
up vote
3
down vote
Use double quotes:
awk -F, '$1=="1" && $31=="C"{print $0}' file
or
awk -F, '$1=="1" && $31=="C"' file
Note that1
doesn't require quotes.
– karakfa
2 days ago
add a comment |
up vote
3
down vote
up vote
3
down vote
Use double quotes:
awk -F, '$1=="1" && $31=="C"{print $0}' file
or
awk -F, '$1=="1" && $31=="C"' file
Use double quotes:
awk -F, '$1=="1" && $31=="C"{print $0}' file
or
awk -F, '$1=="1" && $31=="C"' file
answered 2 days ago
Cyrus
44.1k43375
44.1k43375
Note that1
doesn't require quotes.
– karakfa
2 days ago
add a comment |
Note that1
doesn't require quotes.
– karakfa
2 days ago
Note that
1
doesn't require quotes.– karakfa
2 days ago
Note that
1
doesn't require quotes.– karakfa
2 days ago
add a comment |
up vote
1
down vote
As other users suggested, this can be done using a simple regex. So you can use sed as well as awk
sed '/^1,.*,C$/!d' file
1
If you don't add the delimiters there will be false matches. For example.11,....,NotC
will match as well./^1,.*,C$/!d
should fix this.
– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
add a comment |
up vote
1
down vote
As other users suggested, this can be done using a simple regex. So you can use sed as well as awk
sed '/^1,.*,C$/!d' file
1
If you don't add the delimiters there will be false matches. For example.11,....,NotC
will match as well./^1,.*,C$/!d
should fix this.
– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
add a comment |
up vote
1
down vote
up vote
1
down vote
As other users suggested, this can be done using a simple regex. So you can use sed as well as awk
sed '/^1,.*,C$/!d' file
As other users suggested, this can be done using a simple regex. So you can use sed as well as awk
sed '/^1,.*,C$/!d' file
edited 2 days ago
answered 2 days ago
oguzismail
1,739516
1,739516
1
If you don't add the delimiters there will be false matches. For example.11,....,NotC
will match as well./^1,.*,C$/!d
should fix this.
– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
add a comment |
1
If you don't add the delimiters there will be false matches. For example.11,....,NotC
will match as well./^1,.*,C$/!d
should fix this.
– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
1
1
If you don't add the delimiters there will be false matches. For example.
11,....,NotC
will match as well. /^1,.*,C$/!d
should fix this.– karakfa
2 days ago
If you don't add the delimiters there will be false matches. For example.
11,....,NotC
will match as well. /^1,.*,C$/!d
should fix this.– karakfa
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
@karakfa updated, thanks!
– oguzismail
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184039%2fawk-condition-for-30th-column-of-a-line-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
With a regex:
awk '/^1.*C$/' file
orawk '/^1,.*,C$/' file
– Cyrus
2 days ago