UNIX LINUX IMPORTANT QUESTION ANSWER
for IGNOU BCA MCA Students
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 11:42 equity drwxrwxrwx+ 1 stock_trader Domain Users 0 Jul 15 14:33 stocks/
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 15:30 currency
-rw-r--r-- 1 stock_trader Domain Users 10K Jul 18 12:29 trading.tar
How to view contents of tar file in Unix or Linux
------------------------------ ------------------------------ -
In earlier example of tar command in Unix or Linux we have created a uncompressed tar file called
"trading.tar" now in this example we will see the actual content of that tar file.
-r--r--r-- stock_trader/Domain Users 0 2011-07-15 15:30 currency
-r--r--r-- stock_trader/Domain Users 0 2011-07-15 11:42 equity drwxrwxrwx stock_trader/Domain Users 0 2011-07-15 14:33 stocks/
-rwxrwxrwx stock_trader/Domain Users 0 2011-07-15 14:33
stocks/online_stock_exchanges. txt
here option "t" is used to display content of tar file in unix while options "v" and "f" are for "verbose" and "following". now you can clearly see that all the files which we wanted to be included in tar file are there.
How to extract contents from a tar file in Unix
------------------------------ -----------------------------
In this example of unix tar command we will see how to extract files or directories from a tar file in unix or Linux. We will use same trading.tar file created in earlier example. In this example we will create a directory "trading" and extract contents of trading.tar on that directory.
total 12K
-rw-r--r-- 1 stock_trader Domain Users 10K Jul 18 12:37 trading.tar
Now the directory is empty just trading.tar file
currency equity stocks/
stocks/online_stock_exchanges. txt
This unix tar command will extract content of trading.tar in current directory. "x" is used for extracting. "v" is again for verbose and optional parameter in all our example.
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 11:42 equity drwxr-xr-x+ 1 stock_trader Domain Users 0 Jul 15 14:33 stocks/
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 15:30 currency
-rw-r--r-- 1 stock_trader Domain Users 10K Jul 18 12:37 trading.tar
Now you can see that all the files and directories which were included in tar file (stocks, equity and currency) has been extracted successfully.
How to create tar file in Unix with just specified contents
------------------------------ ------------------------------ -------------
In above example of tar command in unix we have created tar file with all the contents available in current directory but we can also create tar file with selective content as shown in above example.
Now in our current directory we have both files and directories and we just want to include two files equity and currency in our tar file.
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 11:42 equity drwxrwxrwx+ 1 stock_trader Domain Users 0 Jul 15 14:33 stocks/
-r--r--r-- 1 stock_trader Domain Users 0 Jul 15 15:30 currency
-rw-r--r-- 1 stock_trader Domain Users 10K Jul 18 12:29 trading.tar drwxr-xr-x+ 1 stock_trader Domain Users 0 Jul 18 12:46 new/
equity currency
you see only two files equity and currency are included in our tar file.
No comments:
Post a Comment