Answered Questions

  • Extract 2 characters in file

    Hello,I want to extract 2 characters of the first column of the one file, that file has 19 columns, in bash script.the first column is some thing like this 2005-07-25, and I want to extract 07. I wrote this codeawk '{ print $ substr ($1,6, 2)}, but out put is he whole of the column: 2005-07-25! can you help me?

    vishal singh

    • May 8th, 2017

    Awk {print substr($1,1,2)} t1.txt t1.txt NAME AGE GENDER SANTOSH 23 Male ajay 24 Male vijay 24 male

    Code
    1.  

    apoorva

    • Apr 25th, 2017

    Awk -F "-" {print substr($2,0,2)} xdf.txt

  • Construct pipes to execute the following jobs?

    1. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list.2. Output of ls should be displayed on the screen and from this output the lines containing the word ‘poem’ should be counted and the count should be stored in a file. 3. Contents of file1 and file2 should be displayed on the screen and this output should be...

    praveen

    • Apr 11th, 2014

    1. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list. Ans: who | tee users.txt && who | wc -l 2. Output of ls...

    santosh

    • Mar 20th, 2012

    Who;echo "Total number of users: "`who|wc -l`