- Home
- Interview Questions
- Linux File Manipulation
6.
You want to run a binary file, you have permissions to it, but it gives you "Access Denied", what do you need to do?
In order to run an application in Linux you need to add executable permission to the file: in order to change a file mode, you need to use the chmod with the required parameters - chmod +x <filename>.
7.
Given a CSV file "a.csv" , how can you get the first column, of all the rows, into a new file called "result.log"?
cat a.csv | awk -F',' '{print $1}' >> result.log.
8.
You want to create files 1-100.log with the same text "Hello This is a test" in it, how can you do it?
For i in `seq 1 100` ; do echo "Hello this is a test" > $i.log ; done.
9.
You have an xml file (myXML.xml) which is all in one line, how do you convert the xml into a well-formatted XML ?
You can manipulate XML files using the "xmllint" application - xmllint --format myXML.xml.
10.
Given the text file "MyLog.log", which is written backwards, how can you invert the order of the lines?
cat MyLog.log | nl -ba | sort -rn | cut -f2-