barbayjuliette / minishell

minishell project 42
0 stars 0 forks source link

Redirections #6

Open barbayjuliette opened 8 months ago

barbayjuliette commented 8 months ago

mplement redirections: ◦ < should redirect input. ◦ > should redirect output. ◦ << should be given a delimiter, then read the input until a line containing the delimiter is seen. However, it doesn’t have to update the history! ◦ >> should redirect output in append mode

barbayjuliette commented 8 months ago

Several redirections: INPUT: ex: grep hello < file1 < file2 < file3 Tries to open all the files, if any of the files doesn't exist -> error Takes only last one as input. ex: _grep hello < file1 << DELIM < file3 Similar, it will still ask me to write the heredoc, but will use file3 as input

OUTPUT ex; echo hello > file1 >> file2 > file3 For each file, if the file does not exist, it will create it. If the file exists, replaces it with empty file ( if >) or do nothing (if >>) Uses that last one for output

echo hello << DELIM --> Even if no input needed we need to process redirection. Here we will still get the HEREDOC

barbayjuliette commented 8 months ago

HEREDOC:

Check example here: https://linuxize.com/post/bash-heredoc/

grep hello << AB << CD << EF < infile -> Will still give the HEREDOC? even if it is not needed