Interview Quizz Logo

 
  • Home
  • About Us
  • Electronics
  • Computer Science
  • Physics
  • History
  • Contact Us
  • ☰
  1. Computer Science
  2. Programming Technologies
  3. sed (Stream Editor) Interview Question with Answer

sed (Stream Editor) Questions and Answers for Viva

Frequently asked questions and answers of sed (Stream Editor) in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best sed (Stream Editor) Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download sed (Stream Editor) FAQs in PDF form online for academic course, jobs preparations and for certification exams .

Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.




Interview Question and Answer of sed (Stream Editor)


Question-1. How do you save changes to a file in sed?

Answer-1: Use the -i option, e.g., sed -i 's/foo/bar/' file.



Question-2. What does the -e option do in sed?

Answer-2: The -e option allows you to specify multiple commands in one sed command.



Question-3. How do you append a line after a match in sed?

Answer-3: Use the a command, e.g., sed '/pattern/a\new line' file.



Question-4. How do you insert a line before a match in sed?

Answer-4: Use the i command, e.g., sed '/pattern/i\new line' file.



Question-5. How do you delete empty lines in a file using sed?

Answer-5: Use sed '/^$/d' file.



Question-6. How do you match lines that start with a specific pattern?

Answer-6: Use ^ in the pattern, e.g., sed '/^foo/d' deletes lines starting with "foo".



Question-7. How do you match lines that end with a specific pattern?

Answer-7: Use $ in the pattern, e.g., sed '/bar$/d' deletes lines ending with "bar".



Question-8. How do you substitute only the first occurrence in a line?

Answer-8: This is the default behavior, e.g., sed 's/foo/bar/'.



Question-9. How do you substitute the nth occurrence in sed?

Answer-9: Use a number, e.g., sed 's/foo/bar/2' replaces the second occurrence in a line.



Question-10. How do you delete lines between two patterns?

Answer-10: Use sed '/start/,/end/d' file.



Question-11. How do you print the line number along with its content?

Answer-11: Use `sed = file



Question-12. What is the q command in sed?

Answer-12: The q command quits processing after a specified line, e.g., sed '5q' file.



Question-13. How do you replace tabs with spaces in sed?

Answer-13: Use sed 's/\t/ /g' file.



Question-14. How do you duplicate lines using sed?

Answer-14: Use the p command, e.g., sed '2p' file.



Question-15. How do you match a word boundary in sed?

Answer-15: Use \b, e.g., sed '/\bword\b/d'.



Question-16. How do you apply sed commands from a file?

Answer-16: Use sed -f script.sed file.



Question-17. What is the purpose of curly braces {} in sed?

Answer-17: Curly braces group commands for a pattern or range, e.g., sed '/pattern/{cmd1; cmd2}'.



Question-18. How do you replace a string on a specific line in sed?

Answer-18: Specify the line number, e.g., sed '3s/foo/bar/' file.



Question-19. How do you convert uppercase to lowercase in sed?

Answer-19: Use sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' file.



Question-20. How do you convert lowercase to uppercase in sed?

Answer-20: Use sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' file.



Question-21. What is the = command in sed?

Answer-21: The = command prints the line number.



Question-22. How do you remove trailing spaces using sed?

Answer-22: Use sed 's/[[:space:]]*$//' file.



Question-23. How do you remove leading spaces using sed?

Answer-23: Use sed 's/^[[:space:]]*//' file.



Question-24. How do you replace a pattern globally across the file?

Answer-24: Use the g flag, e.g., sed 's/foo/bar/g' file.



Question-25. How do you use backreferences in sed?

Answer-25: Use \1, \2, etc., e.g., sed 's/\(foo\)\(bar\)/\2\1/'.



Question-26. How do you remove duplicate lines in sed?

Answer-26: Use sed '$!N; /^\(.*\)\n\1$/!P; D'.



Question-27. How do you insert a blank line between lines using sed?

Answer-27: Use sed G file.



Question-28. How do you reverse a file using sed?

Answer-28: Use sed '1!G;h;$!d' file.



Question-29. How do you replace a string in a range of lines?

Answer-29: Use sed '2,4s/foo/bar/' file.



Question-30. How do you print lines that do not match a pattern?

Answer-30: Use sed -n '/pattern/!p' file.



Question-31. How do you delete lines matching a regular expression?

Answer-31: Use sed '/regex/d' file.



Question-32. How do you append text to the end of each line?

Answer-32: Use sed 's/$/text/' file.



Question-33. How do you handle multiple files in sed?

Answer-33: Specify multiple files, e.g., sed 's/foo/bar/' file1 file2.



Question-34. What is the ! operator in sed?

Answer-34: The ! operator negates a command, e.g., sed '/pattern/!d' deletes lines not matching the pattern.



Question-35. How do you delete lines with a specific length?

Answer-35: Use sed '/^.\{length\}$/d' file, e.g., sed '/^.\{10\}$/d' for lines of length 10.



Question-36. How do you comment out lines matching a pattern?

Answer-36: Use sed 's/^pattern/#&/' file.



Question-37. How do you replace text only on odd lines in sed?

Answer-37: Use sed '1~2s/foo/bar/' file.



Question-38. How do you replace text only on even lines in sed?

Answer-38: Use sed '2~2s/foo/bar/' file.



Question-39. What is sed?

Answer-39: sed is a stream editor used to perform basic text transformations on an input stream (a file or input from a pipeline).



Question-40. How does sed work?

Answer-40: sed reads input line by line, applies specified operations, and outputs the result.



Question-41. What is the basic syntax of sed?

Answer-41: sed 'command' file, where the command is an operation like substitution.



Question-42. How do you substitute text in sed?

Answer-42: Use s/old/new/, e.g., sed 's/foo/bar/' file.



Question-43. What does the -n option do in sed?

Answer-43: The -n option suppresses automatic printing, allowing only explicitly specified lines to be output.



Question-44. How do you print specific lines in sed?

Answer-44: Use p after the line number, e.g., sed -n '3p' file prints only the third line.



Question-45. What is a range in sed?

Answer-45: A range specifies a start and end line, e.g., sed '1,3d' file deletes lines 1 to 3.



Question-46. How do you delete lines in sed?

Answer-46: Use the d command, e.g., sed '2d' file deletes the second line.



Question-47. How do you replace all occurrences of a string in sed?

Answer-47: Use the g flag, e.g., sed 's/foo/bar/g' file.



Question-48. How do you specify a delimiter other than / in sed?

Answer-48: Use a different character, e.g., `sed 's



Question-49. How do you use sed with input from a pipeline?

Answer-49: Pipe the output to sed, e.g., `echo "foo"



Question-50. What does & represent in a substitution pattern?

Answer-50: & represents the matched string, e.g., sed 's/foo/&bar/' turns "foo" into "foobar".




Tags

Frequently Asked Question and Answer on sed (Stream Editor)

sed (Stream Editor) Interview Questions and Answers in PDF form Online

sed (Stream Editor) Questions with Answers

sed (Stream Editor) Trivia MCQ Quiz

FAQ Questions Sidebar

Related Topics


  • API Testing
  • Python
  • AWS Amazon Web Services
  • Java
  • C++
  • JavaScript
  • C#
  • PHP
  • Swift
  • Ruby
  • Kotlin
  • TypeScript
  • Go Golang
  • Rust
  • SQL
  • R
  • MATLAB
  • Perl
  • Scala
  • Dart
  • Haskell
  • Objective-C
  • Shell Scripting Bash
  • Visual Basic VB
  • Lua
  • Groovy
  • F#
  • Julia
  • COBOL
  • Fortran
  • Assembly Language
  • PL/SQL
  • Scratch
  • D
  • Erlang
  • Elixir
  • Clojure
  • Pascal
  • Ada
  • Lisp Common Lisp, Scheme
  • Prolog
  • Apex Salesforce
  • ActionScript
  • ABAP SAP
  • Racket
  • Nim
  • Crystal
  • Smalltalk
  • VHDL
  • Verilog
  • SASS Syntactically Awesome Style Sheets
  • Less CSS Preprocessor
  • CoffeeScript
  • J Sharp
  • Tcl (Tool Command Language)
  • XQuery
  • XSLT
  • OpenCL
  • CUDA
  • OpenGL Shader Language (GLSL)
  • VBScript
  • Solidity (Blockchain/Smart Contracts)
  • Yaml
  • JSON
  • XML
  • GDScript (Godot Engine)
  • UnrealScript (Unreal Engine)
  • Maple
  • Mathematica
  • Max/MSP
  • AutoLISP
  • LabVIEW
  • ScratchJr
  • AWK
  • sed (Stream Editor)
  • PostScript
  • Xojo
  • Q Sharp
  • Ring
  • ActionScript 3
  • OpenEdge ABL
  • RPG (IBM)
  • Inform
  • Modula-3
  • Rebol
  • Tcl/Tk
  • Haxe
  • SML (Standard ML)
  • Eiffel
  • Chapel
  • Red
  • MUMPS
  • PASCAL ABC
  • Icon
  • BCPL
  • Simula
  • SNOBOL
  • Hack (Meta)
  • PowerShell
  • Batch Script
  • AppleScript
  • Glue
  • Oz
  • Io
  • Mercury
  • Wren
  • Genie
  • PureScript
  • MoonScript
  • Turing
  • ALGOL
  • Seed7
  • Kotlin Native
  • Kotlin Multiplatform
  • Elm
  • PureBasic
  • QB64 (QuickBASIC)
  • Nemerle
  • Ocaml
  • Alloy
  • Cobra
  • Forth
  • Ballerina
  • Deno (JavaScript Runtime)
  • WASM (WebAssembly)
  • Z shell (Zsh)
  • Fish Shell
  • Redscript
  • Felix
  • ReScript
  • Agda
  • Idris
  • Coq
  • SPARK
  • Vala
  • PicoLisp
  • Wolfram Language
  • BASH (Bourne Again Shell)
  • Hy (Lisp-like for Python)
  • Terra
  • Boo
  • ATS
  • K (Kdb+)
  • Picat
  • Nimrod
  • Pawn
  • Papyrus (Bethesda Games)
  • J Programming Language
  • X++
  • MQL4/MQL5 (MetaTrader)
  • Transact-SQL (T-SQL)
  • BASH Shell Scripting

More Subjects


  • Computer Fundamentals
  • Data Structure
  • Programming Technologies
  • Software Engineering
  • Artificial Intelligence and Machine Learning
  • Cloud Computing

All Categories


  • Physics
  • Electronics Engineering
  • Electrical Engineering
  • General Knowledge
  • NCERT CBSE
  • Kids
  • History
  • Industry
  • World
  • Computer Science
  • Chemistry

Can't Find Your Question?

If you cannot find a question and answer in the knowledge base, then we request you to share details of your queries to us Suggest a Question for further help and we will add it shortly in our education database.
© 2025 Copyright InterviewQuizz. Developed by Techgadgetpro.com
Privacy Policy