I need help really quick, this is due in an hour. Here is my new code, I just need to figure out how to get the user input to do the correct command, which is why I left the "if choice" blank...or should it be "if $choice" ?
read -p "How would you like the file to be sorted?
1) Alphabetically by name
2) By Land Area
3) By Population
Enter number choice here: " choice
read choice
if choice
then
awk '{ print $2, $3, $4 }' fifty_states.txt > states_alpha.txt
sort states_alpha.txt
fi
if choice
then
awk '{ print $2, $3, $4 }' fifty_states.txt > states_land.txt
sort -k +1 states_land.txt
fi
if choice
then
awk '{ print $2, $4, $3 }' fifty_states.txt > states_pop.txt
sort -k +1 states_pop.txt
fi
We are not going to do your homework for you.
I suggest again that you look at the man page for the test command so you can craft your if statements to look something like:
or
For e.g I have a file named "relation" which has three coloums i.e
JOHN MARY JACK
PETE ALISIA JONNY
TONY JACKIE VICTOR
If I do
grep -w 'JOHN' relation | awk '{print""$1" is husband of "$2" & father of "$3""}'
It gives out
JOHN i husband of MARY & father of JACK (which is desired... (7 Replies)
Hi,
I have a text file with data in that I wish to extract, assign to a variable and process through a loop.
Kind of the process that I am after:
1: Grep the text file for the values.
Currently using:
cat /root/test.txt | grep TESTING= | awk -F"=" '{ a = $2 } {print a}' | sort -u
... (0 Replies)
hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this;
192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible sort... (8 Replies)
Hi, I'm running via PuTTY, in a BASH shell to do my work. I'm running calculations where steps are reported like this every 100 steps:
NSTEP = 249900 TIME(PS) = 249.900 TEMP(K) = 299.94 PRESS = 21.1
Etot = -12912.5557 EKtot = 4996.8780 EPtot = -17909.4336
... (6 Replies)
Hi,
I need an awk script (or whatever shell-construct) that would take data like below and get the max value of 3 column, when grouping by the 1st column.
clientname,day-of-month,max-users
-----------------------------------
client1,20120610,5
client2,20120610,2
client3,20120610,7... (3 Replies)
I have a question that I am at a loss to solve. I have 3 column tab-separated data, such as:
abs nmod+n+n-commitment-n 349.200023
abs nmod+n+n-a-commitment-n 333.306429
abs into+ns-j+vn-pass-rb-divide-v 295.57316
abs nmod+n+ns-commitment-n 182.085018
abs nmod+n+n-pledge-n ... (2 Replies)
Hi have a large spreadsheet which has 4 columns
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96034 Storage Mgmt Team
APM00111803814 server_2 96152 GWP... (6 Replies)
Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2
Scenario 1
i need to do below changes only when column1 is CR and column3 has duplicates rows/values. This inputfile can contain 100 of this duplicated rows of... (1 Reply)
Example:
I have files in below format
file 1:
zxc,133,joe@example.com
cst,222,xyz@example1.com
File 2 Contains:
hxd
hcd
jws
zxc
cst
File 1 has 50000 lines and file 2 has around 30000 lines :
Expected Output has to be :
hxd
hcd
jws (5 Replies)
Discussion started by: TestPractice
5 Replies
LEARN ABOUT NETBSD
srtconfig
SRTCONFIG(1) BSD General Commands Manual SRTCONFIG(1)NAME
srtconfig -- configure srt interfaces
SYNOPSIS
srtconfig srtX
srtconfig srtX N
srtconfig srtX del N
srtconfig srtX add srcaddr mask dstif dstaddr
srtconfig srtX set N srcaddr mask dstif dstaddr
DESCRIPTION
srtconfig configures, or queries the configuration of, srt(4) interfaces. An srt(4) interface parcels packets out to other interfaces based
on their source addresses (the normal routing mechanisms handle routing decisions based on destination addresses). An interface may have any
number of routing choices; they are examined in order until one matching the packet is found. The packet is sent to the corresponding inter-
face. (Any interface, even another srt interface, may be specified; if the configurations collaborate to cause a packet to loop forever, the
system will lock up or crash.)
When run with only one argument, srtconfig prints the settings for the specified interface.
When run with two arguments, srtconfig prints the settings for the routing choice whose number is given as the second argument.
The form with 'del' deletes a routing choice, identified by its number. Other choices with higher numbers, if any, will be renumbered
accordingly.
The 'add' form adds a choice; the other arguments describe it, and are documented below. The new choice is added at the end of the list.
The 'set' form replaces an existing choice, given its number. The other arguments describe the new choice which is to replace whatever cur-
rently exists at the given number N.
A choice is described by four pieces of information: a source address and mask, which are used to determine which choice an outgoing packet
uses, a destination interface, and a destination address for the new interface. The source address and mask are specified like any Internet
addresses (for convenience, the mask may instead be specified as a '/' followed by a small integer, CIDR-style; note that in this case the
mask must still be a separate argument; it cannot be appended to the end of the source address argument).
Each srt interface also has ordinary source and destination addresses which are set with ifconfig(8) like any other interface; these should
not be confused with any of the above.
AUTHORS
der Mouse <mouse@rodents.montreal.qc.ca>
BSD August 21, 2000 BSD