Write and compile some programs to accomplish the standard Unix commands in Hask
ID: 3777862 • Letter: W
Question
Write and compile some programs to accomplish the standard Unix commands in Haskell. You may find the documentation for the following libraries helpful: System.Directory, System.IO.
"cp" - (copy file) - which takes a from and to arguments.
"pwd" - (print working directory) prints the name of the current directory
"ls" - (list) which lists the names of files in the current directory. Like "dir" on windows.
"cat" - (concatenate files) takes a filename and outputs it's contents to standard output.
Explanation / Answer
1) cp-copy
program:-
in unix:- cp source_file_name destination_file_name;
in haskell:-
2)pwd:-
in unix:- pwd ;
in haskell:- // cmd that simply displays the current working directory
3) ls :- list of files
in unix:- ls;
in haskell:-
4) cat:- concatenate a file
in unix:- cat> a; // opens a file named "a" for writing or displays "a"'s content if any
in haskell:- main = putStrLn "hello world"
how to save compile and run the haskell program: -
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.