10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello Folks,
Need to bisect strings based on a subset.
Below works good.
echo /a/b/c/d | awk -F"/c/d$" '{print $1}'
/a/b
However, it goes awry with special characters.
echo /a/b/c+/d | awk -F"/c+/d$" '{print $1}'
/a/b/c+/d
Desired output:
/a/b
Escaping the special characters... (11 Replies)
Discussion started by: vibhor_agarwali
11 Replies
2. Shell Programming and Scripting
This is really frustrating because I can't figure it out.
I'm running a health check script. One of the items I'm checking is the amount of memory on a server. I use the free command, which outputs something like this (excerpt)
Mem: 100 100 100 100
Swap: 100 100 100 100
In my debugging... (5 Replies)
Discussion started by: JustaDude
5 Replies
3. Shell Programming and Scripting
Hi,
I have a similar input format-
A_1 2
B_0 4
A_1 1
B_2 5
A_4 1
and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks!
letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies
4. Shell Programming and Scripting
Hi Experts.
I'm stuck with the below AWK code where i'm trying to move the records containing any special characters in the last field to a bad file.
awk -F, '{if ($NF ~ /^|^/) print >"goodfile";else print >"badfile"}' filename
sample data
1,abc,def,1234,A *
2,bed,dec,342,* A ... (6 Replies)
Discussion started by: shell_boy23
6 Replies
5. Shell Programming and Scripting
Hi everybody;
I have a code and this fetches data from first.txt,modify it and outputs it to second.txt file.
l awk 'NR>1 {print "l ./gcsw "$1" lt all lset Data="$2" Value "$3}' /home/gcsw/first.txt > /home/gcsw/second.txt
this outputs as:
l ./gcsw 123 lt all lset Data=456 Value 789
... (1 Reply)
Discussion started by: gc_sw
1 Replies
6. Shell Programming and Scripting
I'm using awk '{print $1}' and it works most of the time to print the contents of a mysql query loop, but occationally I get a field with some special character in it, is there a way to tell awk to ignore all special characters between my FS? I have >186K records, so building a list of ALL special... (6 Replies)
Discussion started by: unclecameron
6 Replies
7. Shell Programming and Scripting
Hi friends
I need to splict special character "|" here.
Here is my script which giving error
LINE=INVTRAN|cd /home/msgGoogle
TraxFolderType=`awk -F"|" '{print $1}' $LINE`
filePath=`awk -F"|" '{print $2}' $LINE`
echo "TraxFolderType: "$TraxFolderType
echo "filePath :"$filePath
... (3 Replies)
Discussion started by: krishna9
3 Replies
8. Shell Programming and Scripting
Hi all,
How do I extract a value without special characters? I need to extract the value of %Used from below and if its greater than 80, need to send a notification.
I am doing this right now..Its giving 17%..Is there a way to extract the value and assign it to a variable in one step?
df |grep... (3 Replies)
Discussion started by: sam_78_nyc
3 Replies
9. Shell Programming and Scripting
BEGIN{
printf ("%s\t%s\t%s\t\n", "First Char", "Last Char", "Total Chars");
}
{
chars = split($1, line, //);
charline = line;
firstchar = line;
lastchar = substr(charline,length(charline));
countchar = length(chars);
... (1 Reply)
Discussion started by: knc9233
1 Replies
10. Shell Programming and Scripting
i have this script that searches for a pattern.
However it fails if the pattern includes some
special characters. So far, it fails with the
following strings:
1. -Cr
2. $Mj
3. H'412
would a sed or awk be more effective?
i don't want the users to put the (\)
during the search (they... (5 Replies)
Discussion started by: apalex
5 Replies