sed used for in Linux?sed is a tool to find and change text in files or input streams automatically. It works like a robot that reads text line by line and edits it based on rules you give.
sed?Use: sed 's/apple/orange/' filename. This changes only the first 'apple' in each line to 'orange'.
-n option do in sed?The -n option tells sed to not print anything by default. You then use the p command to print only the lines you want.
sed '2d' filenameThis command deletes the second line from the file output. It reads the file and skips printing line 2.
sed directly to the file?Use the -i option: sed -i 's/old/new/g' filename. This edits the file in place without showing output on screen.
sed 's/cat/dog/' file.txt do?The s/cat/dog/ command replaces only the first 'cat' found in each line with 'dog'.
sed from printing all lines by default?The -n option tells sed not to print lines unless explicitly told to.
sed?The command sed '3d' filename deletes the third line from the output.
g flag do in sed 's/old/new/g'?The g flag means 'global', so it replaces all matches in each line, not just the first.
sed?The -i option edits the file in place, saving changes directly.
sed to replace text in a file and save the changes directly.sed processes input and how you can control what lines get printed.