Tagged Questions
2
votes
2answers
89 views
Awk not rendering any result
My goal is to get the file created in the current month in a directory.
It seems that the command is correct but not rendering any result:
Date=`date '+%b'`
echo $Date
Oct
ls -l | awk -v d="$Date" ...
3
votes
4answers
88 views
Align text to center with padding on both sides
Is there an easy way to align text to the center with padding on both sides, with the column width being the longest line from the input?
For example, this:
aaa
bbbb
c
ddddd
ee
will turn into this ...
1
vote
2answers
62 views
Printing fields using awk
< pool.sam awk '
/./ {printf $1}
{printf $7+1,"\t"}
{printf $3,"\t"}
{
if($2 !=16) {print "\t", "+";} else {print "\t","-";}
{printf $4,"\t" ,length($10)+$4, "\t", "1"}
}'
I am ...
1
vote
3answers
59 views
How to add Multiple Searches in AWK command
Im trying to search for the files Created in June,July and August months. I used this method
ls -lrth|awk '/[Jun][Jul][Aug]/ {print}'
but it ain't working.
Please help me correct the syntax.
2
votes
1answer
51 views
Regular Expressions within a string in AWK using if/then control structure?
PROBLEM
I want to specifically use AWK (GAWK, MAWK, whatever) in an AWK script to sum up the values in field 9 for every record that contains "runner__.jpx" (the underscores are placeholders for two ...
2
votes
3answers
121 views
Comparing files line by line in awk with delimiter
file1:
abc|123|check
def|456|map
ijk|789|globe
lmn|101112|equator
file2:
abc|123|check
def|456|map
ijk|789|equator
lmn|101112|globe
EXPECTED OUTPUT:
ijk|789|equator
lmn|101112|globe
Current ...
4
votes
3answers
402 views
Summing up an array inside of awk?
I have the following piece of code:
sum1=
sum2=
declare -a a
echo $temp | awk '{split($0,a,","); name=a[1] ; for(i=2;i<=4;i++) sum1+=a[i] ; for(i=5;i<=7;i++) sum2+=a[i] }'
This code is ...
4
votes
4answers
123 views
Joining two files with unique identifier
I have two files with approximately 12900 and 4400 entries respectively, that I want to join. The files contain location information for all landbased weather observing stations around the globe.
The ...
0
votes
4answers
87 views
Match multiple regular expressions from a single file using awk
I'm trying to parse a HTML file using shell scripting.
There are 4 different regular expressions that i need to catch: name= , age= , classs= , marks=.
Using
grep "name=\|age=\|class=\|marks=" ...
0
votes
6answers
237 views
Using cut/awk/sed with two different delimiters
I have the following cases:
[email protected]
[email protected]
[email protected]
I'm trying to convert these to
[email protected]
[email protected]
[email protected]
So it should remove everything from ...
1
vote
1answer
84 views
How to integrate a multiline awk script in a shell script
I am a beginner in shell scripting and my question is a continuation of
How to parse a file to extract 3 digits numbers kept in a "group number"
I am trying to integrate in a single shell ...
3
votes
7answers
339 views
Problem in splitting a string using awk or cut command
I have a properties file which has a password field (key value pair)
PASSWORD=NDhhHcsOBofXUdUzGw5B0Q==
I am trying to get the value in my shell script using the awk command
password=`awk -F "=" ...
1
vote
3answers
196 views
Split long output into two columns
Is there a simple utility or script to columnate the output from one of my scripts? I have data in some form:
A aldkhasdfljhaf
B klajsdfhalsdfh
C salkjsdjkladdag
D lseuiorlhisnflkc
E sdjklfhnslkdfhn
...
3
votes
3answers
105 views
checking data in columns when a data or some may be missing or present?
I am not sure if this possible.
say i have columns like :
Team Colour Game Rainfall PlayerName
XYZ Blue Cricket Yes Kapil
suppose i need to search ...
5
votes
4answers
711 views
Show sum of file sizes in directory listing
The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current ...