Question

In: Computer Science

CSCE 3600: Systems Programming Recitation Assignment 3 – Sed and Gawk Due: 06:00 PM on Monday...

CSCE 3600: Systems Programming

Recitation Assignment 3 – Sed and Gawk

Due: 06:00 PM on Monday October 12 2020

DESCRIPTION: In this recitation assignment, you will just practice to run sed and gawk commands and record your work session into a file. In other words, just type and run commands specified in bold Consolas (except $ sign :) below on your terminal.

Let’s start. First, open a terminal (bash) session. Issue the first command

$ script FirsName_LastName_04.txt

where FirsName_LastName_04.txt is a file name with FirstName_LastName replaced with your real names. That command will start recording of your work into that file.

The sed commands: go to one of your directories that contains plenty of files (more than 10)

$ cd name-of-directory-with-more-than-10-files

and then in that directory create a list of files by issuing the following command

$ ls –l > sedfile.txt

Print 5 lines of sedfile.txt file to the terminal using statement

$ sed –n 1,5p sedfile.txt

Replace the first “-“character on lines in the file with “R”

$ sed –i "s/^-/R/g" sedfile.txt

-i option instructs sed to replace the original file with output file it creates.

Print 5 lines of sedfile.txt file again to see what was changed

$ sed –n 1,5p sedfile.txt

Delete the first line in the file

$ sed –i 1d sedfile.txt

Find some pattern on one of the lines in the file (like name, date, or memory size) and issue the following command to add new line after that pattern.

$ sed –i '/YOUR PATTERN/a This will be added as new line'

Print out the first 10 lines of your sedfile.txt file again to verify that these changes (deleting the first line and adding a new line) worked:

$ sed –n 1,10p sedfile.txt

Now let’s work with gawk. Create a list of running processes on your system by issuing the following command from your command prompt as follows:

$ ps –ef > gawkfile.txt

Print gawkfile.txt using the NR system variable as follows:

$ gawk 'NR <= 10' gawkfile.txt

This should display the first 10 lines of your gawkfile.txt file. Processes will be covered in detail a little later on in this course. So how many processes are running on your system?

$ gawk 'END {print NR}' gawkfile.txt

Since our gawkfile.txt file contains a header with the fields, we should have 1 less process running on our system. Let’s try to print out only those processes that only you are running. This means that we want to print out some fields where the UID is your user ID. If you do not know your user ID, you can issue the whoami command at your command prompt to find out.

$ gawk '/YOUR USER ID/{print NR, $0}' gawkfile.txt

Let’s see what is result of matching on the first field ($1)?

$ gawk '$1 ~ /YOUR USER ID/{print NR, $0}' gawkfile.txt

That ensures that only the processes that you own are printed!

We see that the first line of gawkfile.txt contains a header with most likely 8 fields (i.e., UID, PID, PPID, C, STIME, TTY, TIME, and CMD, though there might be some variation in different Linux distributions). However, because we use the default field separator of whitespace, some records might contain more fields. So, let’s print out those records that have more than 8 fields. We use here gawk variables NR and NF.

$ gawk 'NF > 8 {print NR, NF}' gawkfile.txt

Now, we print only fields from 9th to max (NF) on line if line contains more than 8 fields.

$ gawk 'NF>8 {for(i=9; i<=NF; i++) print NR, NF, $i}' gawkfile.txt

Now, we swap the PID (field $2) and PPID (field $3) columns so that each record lists the parents’ process ID first by just printing field in the specified order below (3 before 2).

$ gawk 'BEGIN {OFS="\t"};{print $1,$3,$2,$4,$5,$6,$7,$8}' gawkfile.txt

OFS above is Output Field Separator, so fields in output should be separated by a Tab.

To output result of gawk command to a file instead of terminal you can use redirection

$ gawk 'BEGIN {OFS="\t"};{print $1,$2,$3,$5}' gawkfile.txt > out

Let’s finish your recording session and close your script file

$ exit

You should see now FirsName_LastName_04.txt in the current directory.

REQUIREMENTS: Your typescript file will be graded based largely on whether you completed the work correctly, so you should make sure you obtained meaningful results from each command. • Although this assignment is to be submitted individually (i.e., each student will submit his/her own source code), you may receive assistance from your TA, IA (i.e., Grader), and even other classmates. Please remember that you are ultimately responsible for learning and comprehending this material as the recitation assignments are given in preparation for the minor assignments, which must be completed individually.

SUBMISSION:  You will electronically submit your typescript file FirsName_LastName_04.txt to the Recitation 3 drop box in Canvas by the due date and time. No late recitation assignments will be accepted.

Solutions

Expert Solution

Below is the terminal output as Test, Please refer screenshot of below command output and also script file data at the bottom

Terminal
~$ script FirstName_LastName_04.txt
Script started, file is FirstName_LastName_04.txt
~$ cd DataFiles/
~/DataFiles$ ls -l > sedfile.txt
~/DataFiles$ sed -n 1,5p sedfile.txt
total 12
-rw-r--r-- 1 user user 8 Oct 12 18:45 file1
-rw-r--r-- 1 user user 9 Oct 12 18:47 file10
-rw-r--r-- 1 user user 9 Oct 12 18:47 file11
-rw-r--r-- 1 user user 8 Oct 12 18:45 file2
~/DataFiles$ sed -i "s/^-/R/g" sedfile.txt
~/DataFiles$ sed -n 1,5p sedfile.txt
total 12
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file1
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file10
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file11
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file2

~/DataFiles$ sed -i "/Oct/a New Line" sedfile.txt
~/DataFiles$ sed -n 1,20p sedfile.txt
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file1
New Line
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file10
New Line
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file11
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file2
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file3
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file4
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file5
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file6
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file7
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file8
New Line

~/DataFiles$ ps -ef > gawkfile.txt
~/DataFiles$ gawk 'NR <= 10' gawkfile.txt
UID PID PPID C STIME TTY TIME CMD
user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
user 432 431 0 18:43 pts/1 00:00:00 bash -i
user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
~/DataFiles$ gawk 'END {print NR}' gawkfile.txt
12
~/DataFiles$ whoami
user
~/DataFiles$ gawk '/user/{print NR,$0}' gawkfile.txt
2 user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
3 user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
4 user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
5 user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
6 user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
7 user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
8 user 432 431 0 18:43 pts/1 00:00:00 bash -i
9 user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
10 user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
11 user 827 826 0 18:58 pts/3 00:00:00 bash -i
12 user 1606 827 0 19:37 pts/3 00:00:00 ps -ef
~/DataFiles$ gawk '$1 ~ /user/{print NR,$0}' gawkfile.txt
2 user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
3 user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
4 user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
5 user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
6 user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
7 user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
8 user 432 431 0 18:43 pts/1 00:00:00 bash -i
9 user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
10 user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
11 user 827 826 0 18:58 pts/3 00:00:00 bash -i
12 user 1606 827 0 19:37 pts/3 00:00:00 ps -ef
~/DataFiles$ gawk 'NF > 8 {print NR,NF}' gawkfile.txt
2 17
3 15
4 17
5 23
7 9
8 9
10 9
11 9
12 9
~/DataFiles$ gawk 'NF > 8 {for(i=9;i<=NF;i++)print NR,NF,$i}' gawkfile.txt
2 17 --
2 17 sh
2 17 -c
2 17 env
2 17 -i
2 17 /cocalc/init/init.sh
2 17 $COCALC_PROJECT_ID
2 17 $KUCALC_IMAGE_NAME
2 17 $COCALC_EXTRA_ENV
3 15 -c
3 15 env
3 15 -i
3 15 /cocalc/init/init.sh
3 15 $COCALC_PROJECT_ID
3 15 $KUCALC_IMAGE_NAME
3 15 $COCALC_EXTRA_ENV
4 17 --optimize-for-size
4 17 --gc-interval=1000
4 17 --always-compact
4 17 /cocalc/src/smc-project/local_hub.js
4 17 --tcp_port
4 17 6000
4 17 --raw_port
4 17 6001
4 17 --kucalc
5 23 /usr/sbin/sshd
5 23 -D
5 23 -p
5 23 2222
5 23 -h
5 23 /tmp/.cocalc/ssh_host_rsa_key
5 23 -o
5 23 PidFile=/tmp/.cocalc/sshd.pid
5 23 -f
5 23 /cocalc/init/sshd_config
5 23 [listener]
5 23 0
5 23 of
5 23 10-100
5 23 startups
7 9 FirsName_LastName_04.txt
8 9 -i
10 9 FirstName_LastName_04.txt
11 9 -i
12 9 -ef
~/DataFiles$ gawk 'BEGIN {OFS="\t"};{print $1,$3,$2,$4,$5,$6,$7,$8}' gawkfile.txt
UID PPID PID C STIME TTY TIME CMD
user 0 1 0 18:39 ? 00:00:00 /cocalc/bin/tini
user 1 6 0 18:39 ? 00:00:00 sh
user 6 7 1 18:39 ? 00:00:45 node
user 7 22 0 18:39 ? 00:00:00 sshd:
user 7 338 0 18:40 pts/0 00:00:00 /bin/bash
user 338 431 0 18:43 pts/0 00:00:00 script
user 431 432 0 18:43 pts/1 00:00:00 bash
user 7 762 0 18:57 pts/2 00:00:00 /bin/bash
user 762 826 0 18:58 pts/2 00:00:00 script
user 826 827 0 18:58 pts/3 00:00:00 bash
user 827 1606 0 19:37 pts/3 00:00:00 ps
~/DataFiles$ gawk 'BEGIN {OFS="\t"};{print $1,$2,$3,$5}' gawkfile.txt
UID PID PPID STIME
user 1 0 18:39
user 6 1 18:39
user 7 6 18:39
user 22 7 18:39
user 338 7 18:40
user 431 338 18:43
user 432 431 18:43
user 762 7 18:57
user 826 762 18:58
user 827 826 18:58
user 1606 827 19:37
~/DataFiles$ gawk 'BEGIN {OFS="\t"};{print $1,$2,$3,$5}' gawkfile.txt > out
~/DataFiles$ exit
exit
Script done, file is FirstName_LastName_04.txt

Script FIle created (FirstName_LastName_04.txt)

Script started on 2020-10-12 18:58:25+00:00 [TERM="xterm-256color" TTY="/dev/pts/2" COLUMNS="192" LINES="24"]
]0;~[01;34m~[00m$ cd DataFiles/
]0;~/DataFiles[01;34m~/DataFiles[00m$ ls -l > sedfile.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -n 1,5p sedfile.txt
total 12
-rw-r--r-- 1 user user 8 Oct 12 18:45 file1
-rw-r--r-- 1 user user 9 Oct 12 18:47 file10
-rw-r--r-- 1 user user 9 Oct 12 18:47 file11
-rw-r--r-- 1 user user 8 Oct 12 18:45 file2
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i "s/^-/R/g" sedfile.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i "s/^-/R/g" sedfile.txt
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[6Pn 1,5p[C[C[C[C[C[C[C[C[C[C[C[C[C
total 12
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file1
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file10
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file11
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file2
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i 1d sedfile.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i '/^user/root/a' sedfile.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i '/^user/root/a' sedfile.txt [Ks/^user/root/a'[1P1d sedfile.txt [2@n 1,5p[C[C[C[C[C[C[C[C[C[C[C[C[C[C[1P[1@1[1@0
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file1
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file10
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file11
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file2
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file3
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file4
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file5
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file6
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file7
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file8

]0;~/DataFiles[01;34m~/DataFiles[00m$ sed -i "/Oct/a New Line" sedfile.txt
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[12Pn 1,20p[C[C[C[C[C[C[C[C[C[C[C[C[C
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file1
New Line
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file10
New Line
Rrw-r--r-- 1 user user 9 Oct 12 18:47 file11
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:45 file2
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file3
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file4
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file5
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:46 file6
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file7
New Line
Rrw-r--r-- 1 user user 8 Oct 12 18:47 file8
New Line
]0;~/DataFiles[01;34m~/DataFiles[00m$ ps -ef > gawkfile.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'NR <= 10' gawkfile.txt
UID PID PPID C STIME TTY TIME CMD
user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
user 432 431 0 18:43 pts/1 00:00:00 bash -i
user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'END {print NR}' gawkfile.txt
12
]0;~/DataFiles[01;34m~/DataFiles[00m$ whoami
user
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk '/user/{print NR,$0}' gawkfile.txt
2 user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
3 user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
4 user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
5 user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
6 user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
7 user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
8 user 432 431 0 18:43 pts/1 00:00:00 bash -i
9 user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
10 user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
11 user 827 826 0 18:58 pts/3 00:00:00 bash -i
12 user 1606 827 0 19:37 pts/3 00:00:00 ps -ef
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk '/user/{print NR,$0}' gawkfile.txt [C[C[C[C[C[C[C[1@$[1@1[1@ [1@~[1@
2 user 1 0 0 18:39 ? 00:00:00 /cocalc/bin/tini -- sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
3 user 6 1 0 18:39 ? 00:00:00 sh -c env -i /cocalc/init/init.sh $COCALC_PROJECT_ID $KUCALC_IMAGE_NAME $COCALC_EXTRA_ENV
4 user 7 6 1 18:39 ? 00:00:45 node --optimize-for-size --gc-interval=1000 --always-compact /cocalc/src/smc-project/local_hub.js --tcp_port 6000 --raw_port 6001 --kucalc
5 user 22 7 0 18:39 ? 00:00:00 sshd: /usr/sbin/sshd -D -p 2222 -h /tmp/.cocalc/ssh_host_rsa_key -o PidFile=/tmp/.cocalc/sshd.pid -f /cocalc/init/sshd_config [listener] 0 of 10-100 startups
6 user 338 7 0 18:40 pts/0 00:00:00 /bin/bash
7 user 431 338 0 18:43 pts/0 00:00:00 script FirsName_LastName_04.txt
8 user 432 431 0 18:43 pts/1 00:00:00 bash -i
9 user 762 7 0 18:57 pts/2 00:00:00 /bin/bash
10 user 826 762 0 18:58 pts/2 00:00:00 script FirstName_LastName_04.txt
11 user 827 826 0 18:58 pts/3 00:00:00 bash -i
12 user 1606 827 0 19:37 pts/3 00:00:00 ps -ef
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk '$1 ~ /user/{print NR,$0}' gawkfile.txt
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[5P[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[5@$1 ~ [C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C
[C[C[C[C[C[C[C[C[C[C[C[C[C[Kgawk 'NF > 8 {print NR,NF}' gawkfile.txt
2 17
3 15
4 17
5 23
7 9
8 9
10 9
11 9
12 9
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'NF > 8 {print NR,NF}' gawkfile.txt [1P[1@p[1@f[1@o[1@r[1@([1@i[1@=[1@9[1@;[1@i[1@<[1@=[1@N[1@F[1@;[1@i[1@+[1@+[1@)[C[C[C[C[C[C[C[C[C[C[C[1@,[1@$[1@i
2 17 --
2 17 sh
2 17 -c
2 17 env
2 17 -i
2 17 /cocalc/init/init.sh
2 17 $COCALC_PROJECT_ID
2 17 $KUCALC_IMAGE_NAME
2 17 $COCALC_EXTRA_ENV
3 15 -c
3 15 env
3 15 -i
3 15 /cocalc/init/init.sh
3 15 $COCALC_PROJECT_ID
3 15 $KUCALC_IMAGE_NAME
3 15 $COCALC_EXTRA_ENV
4 17 --optimize-for-size
4 17 --gc-interval=1000
4 17 --always-compact
4 17 /cocalc/src/smc-project/local_hub.js
4 17 --tcp_port
4 17 6000
4 17 --raw_port
4 17 6001
4 17 --kucalc
5 23 /usr/sbin/sshd
5 23 -D
5 23 -p
5 23 2222
5 23 -h
5 23 /tmp/.cocalc/ssh_host_rsa_key
5 23 -o
5 23 PidFile=/tmp/.cocalc/sshd.pid
5 23 -f
5 23 /cocalc/init/sshd_config
5 23 [listener]
5 23 0
5 23 of
5 23 10-100
5 23 startups
7 9 FirsName_LastName_04.txt
8 9 -i
10 9 FirstName_LastName_04.txt
11 9 -i
12 9 -ef
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'NF > 8 {for(i=9;i<=NF;i++)print NR,NF,$i}' gawkfile.txt
[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[21Pprint NR,NF[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[21@for(i=9;i<=NF;i++)print NR,NF,$i[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C
[C[C[C[C[C[C[C[C[C[C[C[C[C[Kgae[K[Kwk [K[K[K[Kgawk 'BEGIN {OFS='[K"\t"};{print $1,$3,$2,$4,$5,$6,$7,$8}' gawkfile.txt
UID   PPID   PID   C   STIME   TTY   TIME   CMD
user   0   1   0   18:39   ?   00:00:00   /cocalc/bin/tini
user   1   6   0   18:39   ?   00:00:00   sh
user   6   7   1   18:39   ?   00:00:45   node
user   7   22   0   18:39   ?   00:00:00   sshd:
user   7   338   0   18:40   pts/0   00:00:00   /bin/bash
user   338   431   0   18:43   pts/0   00:00:00   script
user   431   432   0   18:43   pts/1   00:00:00   bash
user   7   762   0   18:57   pts/2   00:00:00   /bin/bash
user   762   826   0   18:58   pts/2   00:00:00   script
user   826   827   0   18:58   pts/3   00:00:00   bash
user   827   1606   0   19:37   pts/3   00:00:00   ps
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'BEGIN {OFS="\t"};{print $1,$3,$2,$4,$5,$6,$7,$8}' gawkfile.txt [C[1P[1P[1P[C[C[C[1P[1P[1P[C[C[C[1P[1@3[1P[1@2[C[1@,[1@$[1@3[C[C[C[1P[1P[1P[1P[1P[1P[1P[1P[1P
UID   PID   PPID   STIME
user   1   0   18:39
user   6   1   18:39
user   7   6   18:39
user   22   7   18:39
user   338   7   18:40
user   431   338   18:43
user   432   431   18:43
user   762   7   18:57
user   826   762   18:58
user   827   826   18:58
user   1606   827   19:37
]0;~/DataFiles[01;34m~/DataFiles[00m$ gawk 'BEGIN {OFS="\t"};{print $1,$2,$3,$5}' gawkfile.txt > out
]0;~/DataFiles[01;34m~/DataFiles[00m$ exit
exit

Script done on 2020-10-12 19:45:47+00:00 [COMMAND_EXIT_CODE="0"]


Related Solutions

the number of cars arriving at a bank car service between 3:00 pm and 6:00 pm...
the number of cars arriving at a bank car service between 3:00 pm and 6:00 pm on Friday, according to a Poisson process at the rate of 0.3 cars per minute. Calculate the probability that at least 4 cars arrive at the bank between 4:00 pm and 4:10 pm
A boat leaves a dock at 2:00 PM and travels due south at a speed of...
A boat leaves a dock at 2:00 PM and travels due south at a speed of 15 km/hr. Another boat has been heading due east at 20 km/hr and reaches the same dock at 3:00 PM. How many minutes after 2:00 PM were the two boats closest together?
A random sample of 100 customers was chosen in a market between 3:00 and 4:00 PM...
A random sample of 100 customers was chosen in a market between 3:00 and 4:00 PM on a Thursday afternoon. The frequency distribution below shows the distribution for checkout time, in minutes. Checkout Time 1.0-1.9 2.0-2.9 3.0-3.9 4.0-5.9 6.0-6.9 Frequency 8 22 Missing Missing Missing Cumulative Relative Frequency Missing Missing 0.84 0.98 1.00 (a) Complete the frequency table with frequency and cumulative relative frequency. Express the cumulative relative frequency to two decimal places (b) What percentage of checkout times was...
A random sample of 100 customers was chosen in a market between 3:00 and 4:00 PM...
A random sample of 100 customers was chosen in a market between 3:00 and 4:00 PM on a Thursday afternoon. The frequency distribution below shows the distribution for checkout time, in minutes. Checkout Time 1.0-1.9 2.0-2.9 3.0-3.9 4.0-5.9 6.0-6.9 Frequency 8 22 Missing Missing Missing Cumulative Relative Frequency Missing Missing 0.84 0.98 1.00 (a) Complete the frequency table with frequency and cumulative relative frequency. Express the cumulative relative frequency to two decimal places (b) What percentage of checkout times was...
Due: May 10, 2019 at 10:00 PM Briefly summarize the competitive process that transpires from the...
Due: May 10, 2019 at 10:00 PM Briefly summarize the competitive process that transpires from the short-run to the long-run in perfectly competitive market structures and contrast it with what happens during the same time horizons in the monopoly industries. What major differences between a monopoly and a perfectly competitive firm can be clearly seen when comparing the graphs illustrating their short-run average and marginal production cost curves, as well as demand and marginal revenue curves? In what industry structure...
Assume your restaurant is an all-you-can-eat buffet that is open daily from 3:00 PM to 9:00...
Assume your restaurant is an all-you-can-eat buffet that is open daily from 3:00 PM to 9:00 PM. You have the following sign that greets consumers as they come through the front door:             Welcome Everyone!         We hope you enjoy your dining experience with us!                 Buffet Price:                 3:00 PM to 5:00 PM Early Bird $10 per person                 5:00 PM to 9:00 PM Dinner $14 per person                         *Senior Citizens receive a 10 percent discount at any time!...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM ET of week 7. Instructions There are many tools available to assist you as an RN to organize your thoughts, make nursing judgments, and implement the 5 rights of delegation. SBAR – Situation, Background, Assessment, and Recommendation, is a standardized tool used in many institutions that provides a framework to facilitate clear communication between health care providers. The components of SBAR are as follows,...
CSC 101 Assignment 3 Barista Assistant Due Date: Friday, October 30 at 11:59 PM Learning Objectives:...
CSC 101 Assignment 3 Barista Assistant Due Date: Friday, October 30 at 11:59 PM Learning Objectives: Practice combining your knowledge of conditionals, loops, functions, strings, and lists. What to Submit: Write your program in a Python script named barista.py. Submit this file to the Assignment 3 page on Canvas. Description The purpose of this assignment is to write a Python program for a cafe to help baristas create coffee for a customer. Your program will take the customer's order and...
STAT 2023 Assignment 8 Fall 2019 due by 10pm on Monday, October 21 Estimation of the...
STAT 2023 Assignment 8 Fall 2019 due by 10pm on Monday, October 21 Estimation of the Population Mean, Lesson 13 Whitmore Farms sells theAmeraucana hens who lay light blue eggs. A random sample of 64 of these hens produced a mean standing height of 14.4 inches. The standard deviation of standing height of Ameraucana hens is known to be .8 inch. Use this information to answer the rest of the questions on this assignment. 1. What is the point estimate...
PSY 2030-Assignment 3:Chi-Square Tests Due by Sunday, April 12th, at 11:30 PM Scores out of 25...
PSY 2030-Assignment 3:Chi-Square Tests Due by Sunday, April 12th, at 11:30 PM Scores out of 25 points (13 points for Question 1 and 12 points for Question 2) Submit by uploading file(s) within "Assignment 3" on Canvas SHOW YOUR WORK!! Either very clearly type it out (making sure your formulas and integrity/formatting of your formulas are extremely clear) Or write it out by hand and attach a scan or photo of your work Remember that all assignments must reflect your...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT