This document contains sample questions and answers related to commonly used Unix/Linux commands like AWK, GREP, SED and CUT. It provides examples of how to use these commands to perform various text processing tasks like extracting/modifying fields, searching/replacing patterns, sorting files etc. Specifically, it lists 10 questions each for AWK, GREP, SED and 5 for CUT along with the corresponding commands as answers.
বিসিএস ,ব্যাংক ও যে কোন জব পরীক্ষার "কম্পিউটার" বিষয়ের প্রস্তুতির জন্য খুব গুরুত্বপূর্ণ ১০০০ টি বাংলা এমসিকিউ বা নৈব্যত্তিক প্রশ্ন
এই ই-বুক বা নোট থেকে যে কোন প্রতিযোগিতামূলক পরীক্ষার "কম্পিউটার বিষয়ে" সর্বাধিক সংখ্যক প্রশ্ন কমন থাকবে …
Computer related bangla mcq questions with answers for any competitive job
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Ajin Abraham
Mobile Security Framework (MobSF) is an intelligent, all-in-one open source mobile application (Android/iOS) automated pen-testing framework capable of performing static and dynamic analysis. It can be used for effective and fast security analysis of Android and iOS Applications and supports both binaries (APK & IPA) and zipped source code. MobSF can also perform Web API Security testing with it's API Fuzzer that can do Information Gathering, analyze Security Headers, identify Mobile API specific vulnerabilities like XXE, SSRF, Path Traversal, IDOR, and other logical issues related to Session and API Rate Limiting.
This document outlines the content of a Hadoop course taught by Mr. Kalyan, who has 7+ years of real-world experience and holds an M.Tech from IIT Kharagpur. The course covers introductory topics on big data and Hadoop, as well as detailed modules on HDFS, MapReduce, YARN, Pig, Hive, HBase, Zookeeper, and other Hadoop ecosystem technologies. It also includes hands-on instruction on installing and configuring Hadoop clusters in pseudo-distributed and fully-distributed modes.
The document contains screenshots and descriptions of the setup and configuration of a Hadoop cluster. It includes images showing the cluster with different numbers of live and dead nodes, replication settings across nodes, and outputs of commands like fsck and job execution information. The screenshots demonstrate how to view cluster health metrics, manage nodes, and run MapReduce jobs on the Hadoop cluster.
The document provides an overview of Hadoop and HDFS. It discusses key concepts such as what big data is, examples of big data, an overview of Hadoop, the core components of HDFS and MapReduce, characteristics of HDFS including fault tolerance and throughput, the roles of the namenode and datanodes, and how data is stored and replicated in blocks in HDFS. It also answers common interview questions about Hadoop and HDFS.
R.V.S. Kalyan has over 19 years of experience in ERP and 1.5 years in Apache Hadoop development. He has worked as a project manager, technical manager, team lead, and consultant on various ERP and Hadoop projects. His technical skills include Oracle, SQL Server, Navision, Hadoop, Pig, Hive, HBase, and Linux. He holds an MCA from Osmania University and certifications in Navision.
The document provides interview questions and answers related to Hadoop. It discusses common InputFormats in Hadoop like TextInputFormat, KeyValueInputFormat, and SequenceFileInputFormat. It also describes concepts like InputSplit, RecordReader, partitioner, combiner, job tracker, task tracker, jobs and tasks relationship, debugging Hadoop code, and handling lopsided jobs. HDFS, its architecture, replication, and reading files from HDFS is also covered.
বিসিএস ,ব্যাংক ও যে কোন জব পরীক্ষার "কম্পিউটার" বিষয়ের প্রস্তুতির জন্য খুব গুরুত্বপূর্ণ ১০০০ টি বাংলা এমসিকিউ বা নৈব্যত্তিক প্রশ্ন
এই ই-বুক বা নোট থেকে যে কোন প্রতিযোগিতামূলক পরীক্ষার "কম্পিউটার বিষয়ে" সর্বাধিক সংখ্যক প্রশ্ন কমন থাকবে …
Computer related bangla mcq questions with answers for any competitive job
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Ajin Abraham
Mobile Security Framework (MobSF) is an intelligent, all-in-one open source mobile application (Android/iOS) automated pen-testing framework capable of performing static and dynamic analysis. It can be used for effective and fast security analysis of Android and iOS Applications and supports both binaries (APK & IPA) and zipped source code. MobSF can also perform Web API Security testing with it's API Fuzzer that can do Information Gathering, analyze Security Headers, identify Mobile API specific vulnerabilities like XXE, SSRF, Path Traversal, IDOR, and other logical issues related to Session and API Rate Limiting.
This document outlines the content of a Hadoop course taught by Mr. Kalyan, who has 7+ years of real-world experience and holds an M.Tech from IIT Kharagpur. The course covers introductory topics on big data and Hadoop, as well as detailed modules on HDFS, MapReduce, YARN, Pig, Hive, HBase, Zookeeper, and other Hadoop ecosystem technologies. It also includes hands-on instruction on installing and configuring Hadoop clusters in pseudo-distributed and fully-distributed modes.
The document contains screenshots and descriptions of the setup and configuration of a Hadoop cluster. It includes images showing the cluster with different numbers of live and dead nodes, replication settings across nodes, and outputs of commands like fsck and job execution information. The screenshots demonstrate how to view cluster health metrics, manage nodes, and run MapReduce jobs on the Hadoop cluster.
The document provides an overview of Hadoop and HDFS. It discusses key concepts such as what big data is, examples of big data, an overview of Hadoop, the core components of HDFS and MapReduce, characteristics of HDFS including fault tolerance and throughput, the roles of the namenode and datanodes, and how data is stored and replicated in blocks in HDFS. It also answers common interview questions about Hadoop and HDFS.
R.V.S. Kalyan has over 19 years of experience in ERP and 1.5 years in Apache Hadoop development. He has worked as a project manager, technical manager, team lead, and consultant on various ERP and Hadoop projects. His technical skills include Oracle, SQL Server, Navision, Hadoop, Pig, Hive, HBase, and Linux. He holds an MCA from Osmania University and certifications in Navision.
The document provides interview questions and answers related to Hadoop. It discusses common InputFormats in Hadoop like TextInputFormat, KeyValueInputFormat, and SequenceFileInputFormat. It also describes concepts like InputSplit, RecordReader, partitioner, combiner, job tracker, task tracker, jobs and tasks relationship, debugging Hadoop code, and handling lopsided jobs. HDFS, its architecture, replication, and reading files from HDFS is also covered.
Big data interview questions and answersKalyan Hadoop
This document provides an overview of the Hadoop Distributed File System (HDFS), including its goals, design, daemons, and processes for reading and writing files. HDFS is designed for storing very large files across commodity servers, and provides high throughput and reliability through replication. The key components are the NameNode, which manages metadata, and DataNodes, which store data blocks. The Secondary NameNode assists the NameNode in checkpointing filesystem state periodically.
The document provides information on systemd service management commands. It shows examples of using systemctl to start, stop, restart, and check the status of the httpd service. It also displays the output of systemctl status httpd which shows details about the loaded unit, active state, process IDs, and log entries for the Apache HTTP Server service.
Organ donation allows a person to pledge that after death, their organs can be donated to help terminally ill patients. The major organs that can be donated are the heart, lungs, liver, pancreas, kidneys, eyes, heart valves, skin, bones, bone marrow and connective tissues. One donor can potentially help many patients receive organ transplants. For organ donation to occur, the potential donor must meet the criteria for brain death while in the hospital connected to life support systems. Healthy organs should then be transplanted as soon as possible. Anyone can potentially be an organ donor regardless of age, gender or race. Organ donation is legal in India under the Transplantation of Human Organs Act and it provides termin
When performing an investigation it is helpful to be reminded of the powerful options available to the investigator. This document is aimed to be a reference to the tools that could be used.
This document provides instructions on configuring Linux security features such as SSH key-based authentication, firewall rules using iptables, SELinux concepts, and the Fail2ban utility. It discusses generating SSH keys, editing SSH configuration files, setting default firewall policies and rules for input, output, and forwarding, as well as network address translation rules. It also covers SELinux file and process context types and restoring default contexts. Lastly, it explains how to install, configure, and check the status of Fail2ban to automatically ban IPs with too many failed login attempts.
This document provides a quick reference card for common commands and key bindings in the terminal multiplexer program TMUX. It summarizes commands for controlling TMUX at the command line, default key bindings, options for managing panes and windows, commands for clients and sessions, and the vi and emacs modes for copying and pasting text in TMUX.
Red Hat Enterprise Linux roadmap highlights included:
- RHEL 5 focusing on stability and basic hardware enablement, transitioning to production phase 2; RHEL 6 in production phase 1 with feature innovation and maintenance; RHEL 7 planned for 2013 with datacenter efficiency and virtualization/cloud enhancements.
- Upcoming KVM virtualization features focused on scalability, performance, and reliability like live migration and snapshots.
- Kernel developments emphasized optimizations for virtual memory, scheduling, resource management, networking and debugging tools.
- Hardware enablement discussed ongoing and planned support for Intel and ARM platforms, as well as power management and InfiniBand improvements.
This document discusses various topics related to using the UNIX shell for database administration tasks. It provides examples of common shell commands and techniques including piping, redirection, checking file attributes, conditional statements, loops, reading user input, finding open ports, common UNIX tools like grep, awk, and kill processes. It also discusses setting up aliases and choosing the right shell based on features.
This document is the manual for Cacti, an open source network monitoring and graphing tool. It contains instructions for installing Cacti on Unix and Windows systems, including required packages and configuration steps. It also provides basics on how Cacti works including retrieving and storing data, presenting graphs, and creating devices and graphs. Advanced topics covered include customizing data collection and storage using templates, scripts, and queries.
This course provides you with knowledge and skills in the areas of:
1. Sorting numbers
2. Sorting strings
3. Sorting arrays
4. Sorting hashes
This course does not cover sorting algorithms. Instead, it is about sorting various types of data in Perl.
The document contains a list of 7 URLs linking to software distributions:
- The first 4 URLs reference Hadoop, Hive, Python and Maven distributions.
- The remaining 3 URLs link to Tomcat, Hive and Java distributions.
This document discusses recommender systems and provides an overview of key concepts. It begins by discussing the Netflix Prize challenge to improve Netflix's recommendation system. It then covers major challenges in recommender systems like data sparsity and cold starts. Different evaluation metrics and classifications of recommender systems are defined. Similarity-based collaborative filtering recommender algorithms like user-based and item-based are described. The document concludes by discussing Mahout's recommender system implementations and an example CNTV recommendation system.
This document provides an introduction to the awk programming language. It discusses what awk is, different versions of awk, the basic program structure and concepts in awk including patterns, actions, records and fields. The document also provides several examples of using awk to parse files and extract/manipulate data. It highlights advantages of awk such as its interpreted nature which avoids separate edit-compile-test cycles and makes it useful for data reporting and manipulation tasks.
This document provides an overview of AWK scripting and various Unix commands covered on Day 4 of a Unix training session. The agenda includes AWK scripting, advanced commands like compression and archiving, an introduction to the File Transfer Protocol (FTP), and Unix process control. The document then goes into detailed explanations of AWK scripting concepts like patterns and actions, operators, control structures, built-in variables, arrays, functions and more. It also covers commands for file compression, changing file ownership, the tar archiving utility, and using FTP to transfer files between systems.
This document provides an overview of the awk programming language including its syntax, working methodology, built-in variables, operators, and examples. Some key points:
- Awk programs use patterns and actions to process input files line by line. Patterns are matched against each record and associated actions are performed.
- Built-in variables like FS, OFS, RS, NR, NF, FILENAME help manipulate the input/output and provide record information.
- Operators allow arithmetic, string, comparison, assignment and regular expression operations.
- Examples demonstrate using built-ins and operators to count fields, select records, and manipulate data from /etc/passwd.
This document discusses using utilities to accomplish complex tasks in scripts. It covers creating a script to list user information, separately listing directories and files, and identifying changes made to files in a directory. Key utilities discussed include ls, grep, sort, uniq, diff, and tr which can be combined in scripts to manipulate and analyze data in powerful ways. Comments are added to scripts using # and utilities are piped together using |.
Big data interview questions and answersKalyan Hadoop
This document provides an overview of the Hadoop Distributed File System (HDFS), including its goals, design, daemons, and processes for reading and writing files. HDFS is designed for storing very large files across commodity servers, and provides high throughput and reliability through replication. The key components are the NameNode, which manages metadata, and DataNodes, which store data blocks. The Secondary NameNode assists the NameNode in checkpointing filesystem state periodically.
The document provides information on systemd service management commands. It shows examples of using systemctl to start, stop, restart, and check the status of the httpd service. It also displays the output of systemctl status httpd which shows details about the loaded unit, active state, process IDs, and log entries for the Apache HTTP Server service.
Organ donation allows a person to pledge that after death, their organs can be donated to help terminally ill patients. The major organs that can be donated are the heart, lungs, liver, pancreas, kidneys, eyes, heart valves, skin, bones, bone marrow and connective tissues. One donor can potentially help many patients receive organ transplants. For organ donation to occur, the potential donor must meet the criteria for brain death while in the hospital connected to life support systems. Healthy organs should then be transplanted as soon as possible. Anyone can potentially be an organ donor regardless of age, gender or race. Organ donation is legal in India under the Transplantation of Human Organs Act and it provides termin
When performing an investigation it is helpful to be reminded of the powerful options available to the investigator. This document is aimed to be a reference to the tools that could be used.
This document provides instructions on configuring Linux security features such as SSH key-based authentication, firewall rules using iptables, SELinux concepts, and the Fail2ban utility. It discusses generating SSH keys, editing SSH configuration files, setting default firewall policies and rules for input, output, and forwarding, as well as network address translation rules. It also covers SELinux file and process context types and restoring default contexts. Lastly, it explains how to install, configure, and check the status of Fail2ban to automatically ban IPs with too many failed login attempts.
This document provides a quick reference card for common commands and key bindings in the terminal multiplexer program TMUX. It summarizes commands for controlling TMUX at the command line, default key bindings, options for managing panes and windows, commands for clients and sessions, and the vi and emacs modes for copying and pasting text in TMUX.
Red Hat Enterprise Linux roadmap highlights included:
- RHEL 5 focusing on stability and basic hardware enablement, transitioning to production phase 2; RHEL 6 in production phase 1 with feature innovation and maintenance; RHEL 7 planned for 2013 with datacenter efficiency and virtualization/cloud enhancements.
- Upcoming KVM virtualization features focused on scalability, performance, and reliability like live migration and snapshots.
- Kernel developments emphasized optimizations for virtual memory, scheduling, resource management, networking and debugging tools.
- Hardware enablement discussed ongoing and planned support for Intel and ARM platforms, as well as power management and InfiniBand improvements.
This document discusses various topics related to using the UNIX shell for database administration tasks. It provides examples of common shell commands and techniques including piping, redirection, checking file attributes, conditional statements, loops, reading user input, finding open ports, common UNIX tools like grep, awk, and kill processes. It also discusses setting up aliases and choosing the right shell based on features.
This document is the manual for Cacti, an open source network monitoring and graphing tool. It contains instructions for installing Cacti on Unix and Windows systems, including required packages and configuration steps. It also provides basics on how Cacti works including retrieving and storing data, presenting graphs, and creating devices and graphs. Advanced topics covered include customizing data collection and storage using templates, scripts, and queries.
This course provides you with knowledge and skills in the areas of:
1. Sorting numbers
2. Sorting strings
3. Sorting arrays
4. Sorting hashes
This course does not cover sorting algorithms. Instead, it is about sorting various types of data in Perl.
The document contains a list of 7 URLs linking to software distributions:
- The first 4 URLs reference Hadoop, Hive, Python and Maven distributions.
- The remaining 3 URLs link to Tomcat, Hive and Java distributions.
This document discusses recommender systems and provides an overview of key concepts. It begins by discussing the Netflix Prize challenge to improve Netflix's recommendation system. It then covers major challenges in recommender systems like data sparsity and cold starts. Different evaluation metrics and classifications of recommender systems are defined. Similarity-based collaborative filtering recommender algorithms like user-based and item-based are described. The document concludes by discussing Mahout's recommender system implementations and an example CNTV recommendation system.
This document provides an introduction to the awk programming language. It discusses what awk is, different versions of awk, the basic program structure and concepts in awk including patterns, actions, records and fields. The document also provides several examples of using awk to parse files and extract/manipulate data. It highlights advantages of awk such as its interpreted nature which avoids separate edit-compile-test cycles and makes it useful for data reporting and manipulation tasks.
This document provides an overview of AWK scripting and various Unix commands covered on Day 4 of a Unix training session. The agenda includes AWK scripting, advanced commands like compression and archiving, an introduction to the File Transfer Protocol (FTP), and Unix process control. The document then goes into detailed explanations of AWK scripting concepts like patterns and actions, operators, control structures, built-in variables, arrays, functions and more. It also covers commands for file compression, changing file ownership, the tar archiving utility, and using FTP to transfer files between systems.
This document provides an overview of the awk programming language including its syntax, working methodology, built-in variables, operators, and examples. Some key points:
- Awk programs use patterns and actions to process input files line by line. Patterns are matched against each record and associated actions are performed.
- Built-in variables like FS, OFS, RS, NR, NF, FILENAME help manipulate the input/output and provide record information.
- Operators allow arithmetic, string, comparison, assignment and regular expression operations.
- Examples demonstrate using built-ins and operators to count fields, select records, and manipulate data from /etc/passwd.
This document discusses using utilities to accomplish complex tasks in scripts. It covers creating a script to list user information, separately listing directories and files, and identifying changes made to files in a directory. Key utilities discussed include ls, grep, sort, uniq, diff, and tr which can be combined in scripts to manipulate and analyze data in powerful ways. Comments are added to scripts using # and utilities are piped together using |.
27.1.5 lab convert data into a universal formatFreddy Buenaño
This document discusses normalizing log files to a universal format. It provides instructions on normalizing timestamps in log files from different sources to a common human-readable format using AWK commands. The lab works through normalizing timestamps in two sample log files - one from an application and one from an Apache web server. Issues encountered with brackets in the Apache log timestamps are addressed by removing them with a regular expression before conversion. Normalizing log files facilitates centralized collection and analysis of events from diverse sources.
The document provides an overview of the Unix philosophy and basic Unix commands. It discusses that Unix programs should do one thing well, work together through text streams, and that common Unix commands take input from stdin and output to stdout. It then demonstrates and explains basic commands like echo, cat, tac, tee, sed, sort, and awk, as well as input/output redirection, pipes, job control, find, grep, xargs, and par.
The document is a colloquium on using the awk text processing utility. It provides an introduction to awk, explaining that it is useful for parsing structured data files and making precise edits to files. The bulk of the document contains examples of awk commands operating on sample text files, demonstrating how to print fields, select lines, and perform basic math operations like summing columns. The examples illustrate awk's ability to select records, access fields, and execute commands at the start or end of processing a file.
Awk is a data extraction and reporting tool developed in the 1970s at Bell Labs to perform basic text formatting on input streams and files, using a scripting language to take actions on textual data and produce formatted reports. It parses input into fields separated by whitespace that can then be accessed and manipulated through variables like $1, $2, NF, and NR to extract and report on specific fields. Advanced uses include conditioning printing on field values, manipulating field values through pipes and sed, and accumulating calculations with variables over the entire file.
Runtime Environment Of .Net Divya RathoreEsha Yadav
The document discusses the .NET Framework and how it aims to unify programming models, simplify development, and introduce a common language runtime. It covers the design goals of the CLR including making development and deployment easier while providing a robust and secure execution environment. Examples are provided of how tasks like splitting a string that were complex in SQL can be simplified with the .NET Framework.
This document provides an intermediate-level practical guide to using Unix. It covers topics such as redirecting standard input/output to files, filename substitution using wildcards, using shell variables, command substitution, and writing simple shell scripts. Examples are provided to illustrate how to use commands like date, ls, and echo to manipulate files and data. Shell programming concepts like conditional expressions and foreach loops are demonstrated in short scripts.
Software Development Automation With Scripting LanguagesIonela
The Scripting languages are deployed in many operative systems, either in UNIX/Linux or Windows. These languages are developed for general purpose process automation and web programming. But you can consider using them for the software development process in many ways. Among these languages, awk and Perl are suitable for automate and speed up software development for embedded systems, because many embedded systems only have cross tool chain, without powerful IDE supports for process automation.
Awk is a programming language used for processing structured data and generating reports. It allows manipulation of rows and columns in a file. Awk views a text file as records made up of fields, and can perform actions on certain records by using patterns and conditional statements. It supports variables, functions, and regular expressions. Syntax involves specifying an awk script or script file to apply to one or more input files.
This document provides an overview of various Linux utilities for examining files, manipulating text, performing calculations, sorting data, and more. It summarizes the purpose and basic usage of utilities like wc, cat, more, grep, sort, uniq, cut, paste and others. Key functions covered include viewing file contents, searching/filtering text, mathematical operations, ordering lines, and identifying duplicate lines.
This document provides an overview of Linux terminal sessions and system utilities. It discusses employing fundamental utilities like ls, wc, sort, and grep. It also covers managing input/output redirection, special characters, shell variables, environment variables, and creating shell scripts. Key topics include using utilities to list directories, count file elements, sort lines, and locate specific lines. It also discusses starting additional terminal sessions, exiting sessions, and locating the graphical terminal.
Why is Azure Data Explorer fast in petabyte-scale analytics?Sheik Uduman Ali
Azure Data Explorer (ADX) uses a columnar data storage architecture that stores columns together in separate files for efficient querying. It shards or partitions data across nodes to allow for distributed querying and scale-out performance. The columnar storage, compression, indexing and sharding approach enables ADX to perform fast analytics on petabyte-scale data.
Program 1 – CS 344This assignment asks you to write a bash.docxwkyra78
Program 1 – CS 344
This assignment asks you to write a bash shell script to compute statistics. The purpose
is to get you familiar with the Unix shell, shell programming, Unix utilities, standard
input, output, and error, pipelines, process ids, exit values, and signals.
What you’re going to submit is your script, called stats.
Overview
NOTE: For this assignment, make sure that you are using Bash as your shell (on Linux,
/bin/sh is Bash, but on other Unix O/S, it is not). This is because the Solaris version of
Bourne shell has some annoying bugs that are really brought out by this script. Bash can
execute any /bin/sh script.
In this assignment you will write a Bourne shell script to calculate averages and medians
from an input file of numbers. This is the sort of calculation I might do when figuring
out the grades for this course. The input file will have whole number values separated by
tabs, and each line of this file will have the same number of values. (For example, each
row might be the scores of a student on assignments.) Your script should be able to
calculate the average and median across the rows (like I might do to calculate an
individual student's course grade) or down the columns (like I might do to find the
average score on an assignment).
You will probably need commands like these, so please read up on them: sh, read, expr,
cut, head, tail, wc, and sort.
Your script will be called stats. The general format of the stats command is
stats {-rows|-cols} [input_file]
Note that when things are in curly braces separated by a vertical bar, it means you should
choose one of the things; here for example, you must choose either -rows or -cols. The
option -rows calculates the average and median across the rows; the option -cols
calculates the average and median down the columns. When things are in square braces
it means they are optional; you can include them or not, as you choose. If you specify an
input_file the data is read from that file; otherwise, it is read from standard input.
Here is a sample run of what your script might return, using an input file called test_file
(this particular one can be downloaded here , note that in Windows, the newline
characters may not display as newlines. Move this to your UNIX account, without
opening and saving it in Windows, and then cat it out: you'll see the newlines there):
% cat test_file
1 1 1 1 1
9 3 4 5 5
6 7 8 9 7
3 6 8 9 1
3 4 2 1 4
6 4 4 7 7
% stats -rows test_file
Average Median
1 1
5 5
7 7
5 6
3 3
6 6
% cat test_file | stats –c
Averages:
5 4 5 5 4
Medians:
6 4 4 7 5
% echo $?
0
% stats
Usage: stats {-rows|-cols} [file]
% stats -r test_file nya-nya-nya
Usage: stats {-rows|-cols} [file]
% stats -both test_file
Usage: stats {-rows|-cols} [file]
% chmod -r test_file
% stats -columns test_file
stats: cannot read test_file
% stats -columns no_such_file
stats: cannot read no_such_file
% echo $?
1
Specifications
You must ch ...
The document discusses an integrated development environment (IDE) for C++ programming. It describes the key components of an IDE, including editing windows for code, project windows to organize files, compilers, linkers and libraries. It provides an example of creating a new project in the Symantec IDE and the code it generates to get started. It also summarizes the typical menus and functions found in most IDEs, such as file operations, editing commands, and options to run and compile a program.
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
CS 23001 Computer Science II: Data Structures & Abstraction
Project #4
Spring 2015
Objectives:
· Develop and use a Tree ADT (n-ary)
· Apply and use tree traversal algorithms
· Manipulate trees by inserting and deleting nodes
· Apply and use STL
Problem:
Build a program profiler. Construct a program to instrument C++ source code to support program profiling.
It is often important to determine how many times a function or statement is executed. This is useful not only for debugging but for determining what parts of a program may need to be optimized. This process is called profiling. That is, a execution profile presents how many times each part of a program is executed using a given set of input data (or for some run time scenario). To compute a profile, statements need to be added to the code that keep track of how many times a function or statement is executed. The process of adding these statements is called instrumenting the code.
To implement a profiler one must first parse the source code and generate an Abstract Syntax Tree (AST) of the code. Each node of the AST describes the syntactic category of the code stored within it (function, statement, while-statement, etc.). So at the top level is a syntactic category corresponding to a program, class, or function (such as in the case of a main). Under that are sub-trees that further detail the syntactic categories of each part of the code. Such things as declarations, parameter lists, while-statement, and expression statements will describe the various parts of the program.
After the AST is generated it can then be traversed and the appropriate syntactic structures can be found that need to be instrumented. Once a construct is found, say a function, new code can be inserted that keeps track of how many times that function is executed.
The most difficult part of constructing a profiler is correctly parsing the source code. Unfortunately, C++ is notoriously difficult to parse. So here we will use a parsing tool called src2srcml. This tool reads in C++ code and marks up the code with XML tags (e.g., block, if, while, condition, name, etc). That is, the output is an AST in XML. The XML representation is called srcML (source code markup language).
A number of srcML data files are provided for the project. However, you can use your own program as input. To run srcML on wasp or hornet you will first need to set a PATH variable so the command can be found. You need to execute the command:
export PATH=/local/opt/srcml/bin:$PATH
It is best if you insert this line into your .bash_profile file in your home directory on wasp/hornet.
Then to generate the srcML file for your own code use the following:
src2srcml main.cpp -o main.cpp.xml
Use the following for a list of all options:
src2srcml --help
More information about srcML can be found at www.srcML.org including a list of all the tag names (see Getting Started). You can also download srcML if you want it on your own machine.
Your .
This document provides an overview of the AWK scripting language including:
- A brief history of AWK and its variants such as GNU AWK.
- An explanation of how AWK scripts work by processing text files line by line and assigning data to columns based on field separators.
- Examples of common tasks that can be accomplished with AWK like managing databases, generating reports, and validating data.
- An overview of the syntax used to write and execute AWK scripts, including specifying patterns and actions, setting variables, and using built-in variables.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Community pharmacy- Social and preventive pharmacy UNIT 5
Unix interview questions
1. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 1/18
Awk is powerful tool in Unix. Awk is an excellent tool for processing the files which have data arranged in
rows and columns format. It is a good filter and report writer.
1. How to run awk command specified in a file?
awk f filename
2. Write a command to print the squares of numbers from 1 to 10 using awk command
awk 'BEGIN { for(i=1;i<=10;i++) {print "square of",i,"is",i*i;}}'
3. Write a command to find the sum of bytes (size of file) of all files in a directory.
ls l | awk 'BEGIN {sum=0} {sum = sum + $5} END {print sum}'
4. In the text file, some lines are delimited by colon and some are delimited by space. Write a command to
print the third field of each line.
awk '{ if( $0 ~ /:/ ) { FS=":"; } else { FS =" "; } print $3 }' filename
5. Write a command to print the line number before each line?
awk '{print NR, $0}' filename
6. Write a command to print the second and third line of a file without using NR.
awk 'BEGIN {RS="";FS="n"} {print $2,$3}' filename
7. Write a command to print zero byte size files?
ls l | awk '/^/ {if ($5 !=0 ) print $9 }'
8. Write a command to rename the files in a directory with "_new" as postfix?
ls F | awk '{print "mv "$1" "$1".new"}' | sh
9. Write a command to print the fields in a text file in reverse order?
awk 'BEGIN {ORS=""} { for(i=NF;i>0;i) print $i," "; print "n"}' filename
10. Write a command to find the total number of lines in a file without using NR
awk 'BEGIN {sum=0} {sum=sum+1} END {print sum}' filename
Another way to print the number of lines is by using the NR. The command is
awk 'END{print NR}' filename
The grep is one of the powerful tools in unix. Grep stands for "global search for regular expressions and
print". The power of grep lies in using regular expressions mostly.
UNIX INTERVIEW QUESTIONS
UNIX INTERVIEW QUESTIONS ON AWK COMMAND
UNIX INTERVIEW QUESTIONS ON GREP COMMAND
2. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 2/18
The general syntax of grep command is
grep [options] pattern [files]
1. Write a command to print the lines that has the the pattern "july" in all the files in a particular directory?
grep july *
This will print all the lines in all files that contain the word “july” along with the file name. If any of the files
contain words like "JULY" or "July", the above command would not print those lines.
2. Write a command to print the lines that has the word "july" in all the files in a directory and also
suppress the filename in the output.
grep h july *
3. Write a command to print the lines that has the word "july" while ignoring the case.
grep i july *
The option i make the grep command to treat the pattern as case insensitive.
4. When you use a single file as input to the grep command to search for a pattern, it won't print the
filename in the output. Now write a grep command to print the filename in the output without using the 'H'
option.
grep pattern filename /dev/null
The /dev/null or null device is special file that discards the data written to it. So, the /dev/null is always an
empty file.
Another way to print the filename is using the 'H' option. The grep command for this is
grep H pattern filename
5. Write a Unix command to display the lines in a file that do not contain the word "july"?
grep v july filename
The 'v' option tells the grep to print the lines that do not contain the specified pattern.
6. Write a command to print the file names in a directory that has the word "july"?
grep l july *
The 'l' option make the grep command to print only the filename without printing the content of the file. As
soon as the grep command finds the pattern in a file, it prints the pattern and stops searching other lines
in the file.
7. Write a command to print the file names in a directory that does not contain the word "july"?
grep L july *
The 'L' option makes the grep command to print the filenames that do not contain the specified pattern.
8. Write a command to print the line numbers along with the line that has the word "july"?
grep n july filename
The 'n' option is used to print the line numbers in a file. The line numbers start from 1
9. Write a command to print the lines that starts with the word "start"?
grep '^start' filename
The '^' symbol specifies the grep command to search for the pattern at the start of the line.
3. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 3/18
10. Write a command to print the lines which end with the word "end"?
grep 'end$' filename
The '$' symbol specifies the grep command to search for the pattern at the end of the line.
11. Write a command to select only those lines containing "july" as a whole word?
grep w july filename
The 'w' option makes the grep command to search for exact whole words. If the specified pattern is found
in a string, then it is not considered as a whole word. For example: In the string "mikejulymak", the pattern
"july" is found. However "july" is not a whole word in that string.
UNIX INTERVIEW QUESTIONS ON SED COMMAND
SED is a special editor used for modifying files automatically.
1. Write a command to replace the word "bad" with "good" in file?
sed s/bad/good/ < filename
2. Write a command to replace the word "bad" with "good" globally in a file?
sed s/bad/good/g < filename
3. Write a command to replace the character '/' with ',' in a file?
sed 's///,/' < filename
sed 's|/|,|' < filename
4. Write a command to replace the word "apple" with "(apple)" in a file?
sed s/apple/(&)/ < filename
5. Write a command to switch the two consecutive words "apple" and "mango" in a file?
sed 's/(apple) (mango)/2 1/' < filename
6. Write a command to replace the second occurrence of the word "bat" with "ball" in a file?
sed 's/bat/ball/2' < filename
7. Write a command to remove all the occurrences of the word "jhon" except the first one in
a line with in the entire file?
sed 's/jhon//2g' < filename
8. Write a command to remove the first number on line 5 in file?
sed '5 s/[09][09]*//' < filename
9. Write a command to remove the first number on all lines that start with "@"?
sed ',^@, s/[09][09]*//' < filename
10. Write a command to replace the word "gum" with "drum" in the first 100 lines of a file?
sed '1,00 s/gum/drum/' < filename
11. write a command to replace the word "lite" with "light" from 100th line to last line in a
file?
sed '100,$ s/lite/light/' < filename
4. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 4/18
12. Write a command to remove the first 10 lines from a file?
sed '1,10 d' < filename
13. Write a command to duplicate each line in a file?
sed 'p' < filename
14. Write a command to duplicate empty lines in a file?
sed '/^$/ p' < filename
15. Write a sed command to print the lines that do not contain the word "run"?
sed n '/run/!p' < filename
UNIX INTERVIEW QUESTIONS ON CUT COMMAND
The cut command is used to used to display selected columns or fields from each line of a
file. Cut command works in two modes:
Delimited selection: The fields in the line are delimited by a single character like
blank,comma etc.
Range selection: Each field starts with certain fixed offset defined as range.
1. Write a command to display the third and fourth character from each line of a file?
cut c 3,4 filename
2. Write a command to display the characters from 10 to 20 from each line of a file?
cut c 1020 filename
3. Write a command to display the first 10 characters from each line of a file?
cut c 10 filename
4. Write a comamnd to display from the 10th character to the end of the line?
cut c 10 filename
5. The fields in each line are delimited by comma. Write a command to display third field
from each line of a file?
cut d',' f2 filename
6. Write a command to print the fields from 10 to 20 from each line of a file?
cut d',' f1020 filename
7. Write a command to print the first 5 fields from each line?
cut d',' f5 filename
8. Write a command to print the fields from 10th to the end of the line?
cut d',' f10 filename
9. By default the cut command displays the entire line if there is no delimiter in it. Which cut
option is used to supress these kind of lines?
The s option is used to supress the lines that do not contain the delimiter.
10. Write a cut command to extract the username from 'who am i' comamnd?
5. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 5/18
who am i | cut f1 d' '
UNIX INTERVIEW QUESTIONS ON FIND COMMAND
Find utility is used for searching files using the directory information.
1. Write a command to search for the file 'test' in the current directory?
find name test type f
2. Write a command to search for the file 'temp' in '/usr' directory?
find /usr name temp type f
3. Write a command to search for zero byte size files in the current directory?
find size 0 type f
4. Write a command to list the files that are accessed 5 days ago in the current directory?
find atime 5 type f
5. Write a command to list the files that were modified 5 days ago in the current directory?
find mtime 5 type f
6. Write a command to search for the files in the current directory which are not owned by
any user in the /etc/passwd file?
find . nouser type f
7. Write a command to search for the files in '/usr' directory that start with 'te'?
find /usr name 'te*' type f
8. Write a command to search for the files that start with 'te' in the current directory and
then display the contents of the file?
find . name 'te*' type f exec cat {} ;
9. Write a command to list the files whose status is changed 5 days ago in the current
directory?
find ctime 5 type f
10. Write a command to list the files in '/usr' directory that start with 'ch' and then display the
number of lines in each file?
find /usr name 'ch*' type f exec wc l {} ;
TOP UNIX INTERVIEW QUESTIONS PART 1
1. How to display the 10th line of a file?
head -10 filename | tail -1
2. How to remove the header from a file?
6. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 6/18
sed -i '1 d' filename
3. How to remove the footer from a file?
sed -i '$ d' filename
4. Write a command to find the length of a line in a file?
The below command can be used to get a line from a file.
sed –n '<n> p' filename
We will see how to find the length of 10th line in a file
sed -n '10 p' filename|wc -c
5. How to get the nth word of a line in Unix?
cut –f<n> -d' '
6. How to reverse a string in unix?
echo "java" | rev
7. How to get the last word from a line in Unix file?
echo "unix is good" | rev | cut -f1 -d' ' | rev
8. How to replace the nth line in a file with a new line in Unix?
sed -i'' '10 d' filename # d stands for delete
sed -i'' '10 i new inserted line' filename # i stands for insert
9. How to check if the last command was successful in Unix?
7. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 7/18
echo $?
10. Write command to list all the links from a directory?
ls -lrt | grep "^l"
11. How will you find which operating system your system is running on in UNIX?
uname -a
12. Create a readonly file in your home directory?
touch file; chmod 400 file
13. How do you see command line history in UNIX?
The 'history' command can be used to get the list of commands that we are executed.
14. How to display the first 20 lines of a file?
By default, the head command displays the first 10 lines from a file. If we change the option
of head, then we can display as many lines as we want.
head -20 filename
An alternative solution is using the sed command
sed '21,$ d' filename
The d option here deletes the lines from 21 to the end of the file
15. Write a command to print the last line of a file?
The tail command can be used to display the last lines from a file.
tail -1 filename
Alternative solutions are:
8. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 8/18
sed -n '$ p' filename
awk 'END{print $0}' filename
TOP UNIX INTERVIEW QUESTIONS PART 2
1. How do you rename the files in a directory with _new as suffix?
ls -lrt|grep '^-'| awk '{print "mv "$9" "$9".new"}' | sh
2. Write a command to convert a string from lower case to upper case?
echo "apple" | tr [a-z] [A-Z]
3. Write a command to convert a string to Initcap.
echo apple | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'
4. Write a command to redirect the output of date command to multiple files?
The tee command writes the output to multiple files and also displays the output on the
terminal.
date | tee -a file1 file2 file3
5. How do you list the hidden files in current directory?
ls -a | grep '^.'
6. List out some of the Hot Keys available in bash shell?
Ctrl+l Clears the Screen.
Ctrl+r Does a search in previously given commands in shell.
Ctrl+u Clears the typing before the hotkey.
Ctrl+a Places cursor at the beginning of the command at shell.
Ctrl+e Places cursor at the end of the command at shell.
Ctrl+d Kills the shell.
Ctrl+z Places the currently running process into background.
9. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outlin… 9/18
7. How do you make an existing file empty?
cat /dev/null > filename
8. How do you remove the first number on 10th line in file?
sed '10 s/[0-9][0-9]*//' < filename
9. What is the difference between join v and join a?
join -v : outputs only matched lines between two files.
join -a : In addition to the matched lines, this will output unmatched lines also.
10. How do you display from the 5th character to the end of the line from a file?
cut -c 5- filename
TOP UNIX INTERVIEW QUESTIONS PART 3
1. Display all the files in current directory sorted by size?
ls -l | grep '^-' | awk '{print $5,$9}' |sort -n|awk '{print $2}'
2. Write a command to search for the file 'map' in the current directory?
find -name map -type f
3. How to display the first 10 characters from each line of a file?
cut -c -10 filename
4. Write a command to remove the first number on all lines that start with "@"?
sed ',^@, s/[0-9][0-9]*//' < filename
10. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 10/18
5. How to print the file names in a directory that has the word "term"?
grep -l term *
The 'l' option make the grep command to print only the filename without printing the
content of the file. As soon as the grep command finds the pattern in a file, it prints the
pattern and stops searching other lines in the file.
6. How to run awk command specified in a file?
awk -f filename
7. How do you display the calendar for the month march in the year 1985?
The cal command can be used to display the current month calendar. You can pass the
month and year as arguments to display the required year, month combination calendar.
cal 03 1985
This will display the calendar for the March month and year 1985.
8. Write a command to find the total number of lines in a file?
wc -l filename
Other ways to print the total number of lines are
awk 'BEGIN {sum=0} {sum=sum+1} END {print sum}' filename
awk 'END{print NR}' filename
9. How to duplicate empty lines in a file?
sed '/^$/ p' < filename
10. Explain iostat, vmstat and netstat?
Iostat: reports on terminal, disk and tape I/O activity.
Vmstat: reports on virtual memory statistics for processes, disk, tape and CPU
activity.
11. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 11/18
1. How do you write the contents of 3 files into a single file?
cat file1 file2 file3 > file
2. How to display the fields in a text file in reverse order?
awk 'BEGIN {ORS=""} { for(i=NF;i>0;i--) print $i," "; print "n"}' filename
3. Write a command to find the sum of bytes (size of file) of all files in a directory.
ls -l | grep '^-'| awk 'BEGIN {sum=0} {sum = sum + $5} END {print sum}'
4. Write a command to print the lines which end with the word "end"?
grep 'end$' filename
The '$' symbol specifies the grep command to search for the pattern at the end of the line.
5. Write a command to select only those lines containing "july" as a whole word?
grep -w july filename
The 'w' option makes the grep command to search for exact whole words. If the specified pattern is found
in a string, then it is not considered as a whole word. For example: In the string "mikejulymak", the pattern
"july" is found. However "july" is not a whole word in that string.
6. How to remove the first 10 lines from a file?
sed '1,10 d' < filename
7. Write a command to duplicate each line in a file?
sed 'p' < filename
Netstat: reports on the contents of network data structures.
TOP UNIX INTERVIEW QUESTIONS PART 4
12. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 12/18
8. How to extract the username from 'who am i' comamnd?
who am i | cut -f1 -d' '
9. Write a command to list the files in '/usr' directory that start with 'ch' and then display the number of
lines in each file?
wc -l /usr/ch*
Another way is
find /usr -name 'ch*' -type f -exec wc -l {} ;
10. How to remove blank lines in a file ?
grep -v ‘^$’ filename > new_filename
1. How to display the processes that were run by your user name ?
ps -aef | grep <user_name>
2. Write a command to display all the files recursively with path under current directory?
find . -depth -print
3. Display zero byte size files in the current directory?
find -size 0 -type f
4. Write a command to display the third and fifth character from each line of a file?
cut -c 3,5 filename
TOP UNIX INTERVIEW QUESTIONS PART 5
13. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 13/18
5. Write a command to print the fields from 10th to the end of the line. The fields in the line are delimited
by a comma?
cut -d',' -f10- filename
6. How to replace the word "Gun" with "Pen" in the first 100 lines of a file?
sed '1,00 s/Gun/Pen/' < filename
7. Write a Unix command to display the lines in a file that do not contain the word "RAM"?
grep -v RAM filename
The 'v' option tells the grep to print the lines that do not contain the specified pattern.
8. How to print the squares of numbers from 1 to 10 using awk command
awk 'BEGIN { for(i=1;i<=10;i++) {print "square of",i,"is",i*i;}}'
9. Write a command to display the files in the directory by file size?
ls -l | grep '^-' |sort -nr -k 5
10. How to find out the usage of the CPU by the processes?
The top utility can be used to display the CPU usage by the processes.
TOP UNIX INTERVIEW QUESTIONS PART 6
1. Write a command to remove the prefix of the string ending with '/'.
The basename utility deletes any prefix ending in /. The usage is mentioned below:
basename /usr/local/bin/file
This will display only file
2. How to display zero byte size files?
14. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 14/18
ls -l | grep '^-' | awk '/^-/ {if ($5 !=0 ) print $9 }'
3. How to replace the second occurrence of the word "bat" with "ball" in a file?
sed 's/bat/ball/2' < filename
4. How to remove all the occurrences of the word "jhon" except the first one in a line with in
the entire file?
sed 's/jhon//2g' < filename
5. How to replace the word "lite" with "light" from 100th line to last line in a file?
sed '100,$ s/lite/light/' < filename
6. How to list the files that are accessed 5 days ago in the current directory?
find -atime 5 -type f
7. How to list the files that were modified 5 days ago in the current directory?
find -mtime 5 -type f
8. How to list the files whose status is changed 5 days ago in the current directory?
find -ctime 5 -type f
9. How to replace the character '/' with ',' in a file?
sed 's///,/' < filename
sed 's|/|,|' < filename
10. Write a command to find the number of files in a directory.
ls -l|grep '^-'|wc -l
15. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 15/18
TOP UNIX INTERVIEW QUESTIONS PART 7
1. Write a command to display your name 100 times.
The Yes utility can be used to repeatedly output a line with the specified string or 'y'.
yes <your_name> | head -100
2. Write a command to display the first 10 characters from each line of a file?
cut -c -10 filename
3. The fields in each line are delimited by comma. Write a command to display third field
from each line of a file?
cut -d',' -f2 filename
4. Write a command to print the fields from 10 to 20 from each line of a file?
cut -d',' -f10-20 filename
5. Write a command to print the first 5 fields from each line?
cut -d',' -f-5 filename
6. By default the cut command displays the entire line if there is no delimiter in it. Which cut
option is used to suppress these kind of lines?
The s option is used to suppress the lines that do not contain the delimiter.
7. Write a command to replace the word "bad" with "good" in file?
sed s/bad/good/ < filename
8. Write a command to replace the word "bad" with "good" globally in a file?
sed s/bad/good/g < filename
16. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 16/18
9. Write a command to replace the word "apple" with "(apple)" in a file?
sed s/apple/(&)/ < filename
10. Write a command to switch the two consecutive words "apple" and "mango" in a file?
sed 's/(apple) (mango)/2 1/' < filename
11. Write a command to display the characters from 10 to 20 from each line of a file?
cut -c 10-20 filename
TOP UNIX INTERVIEW QUESTIONS PART 8
1. Write a command to print the lines that has the the pattern "july" in all the files in a
particular directory?
grep july *
This will print all the lines in all files that contain the word “july” along with the file name. If
any of the files contain words like "JULY" or "July", the above command would not print
those lines.
2. Write a command to print the lines that has the word "july" in all the files in a directory
and also suppress the file name in the output.
grep -h july *
3. Write a command to print the lines that has the word "july" while ignoring the case.
grep -i july *
The option i make the grep command to treat the pattern as case insensitive.
4. When you use a single file as input to the grep command to search for a pattern, it won't
print the filename in the output. Now write a grep command to print the file name in the
output without using the 'H' option.
grep pattern file name /dev/null
17. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 17/18
The /dev/null or null device is special file that discards the data written to it. So, the /dev/null
is always an empty file.
Another way to print the file name is using the 'H' option. The grep command for this is
grep -H pattern filename
5. Write a command to print the file names in a directory that does not contain the word
"july"?
grep -L july *
The 'L' option makes the grep command to print the file names that do not contain the
specified pattern.
6. Write a command to print the line numbers along with the line that has the word "july"?
grep -n july filename
The 'n' option is used to print the line numbers in a file. The line numbers start from 1
7. Write a command to print the lines that starts with the word "start"?
grep '^start' filename
The '^' symbol specifies the grep command to search for the pattern at the start of the line.
8. In the text file, some lines are delimited by colon and some are delimited by space. Write
a command to print the third field of each line.
awk '{ if( $0 ~ /:/ ) { FS=":"; } else { FS =" "; } print $3 }' filename
9. Write a command to print the line number before each line?
awk '{print NR, $0}' filename
10. Write a command to print the second and third line of a file without using NR.
18. 3/26/2015 UNIX INTERVIEW QUESTIONS
data:text/html;charset=utf-8,%3Cdiv%20class%3D%22article-header%22%20style%3D%22margin%3A%200px%3B%20outli… 18/18
awk 'BEGIN {RS="";FS="n"} {print $2,$3}' filename
11. How to create an alias for the complex command and remove the alias?
The alias utility is used to create the alias for a command. The below command creates
alias for ps aef command.
alias pg='ps -aef'
If you use pg, it will work the same way as ps aef.
To remove the alias simply use the unalias command as
unalias pg
12. Write a command to display today's date in the format of 'yyyymmdd'?
The date command can be used to display today's date with time
date '+%Y-%m-%d'