Find the answer to your Linux question:
Results 1 to 4 of 4
Hello my friends,I'm a new learner to programming in Linux so kindly can you help me to write this simple script for me and it is lists all text files ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6

    Find and write to a files

    Hello my friends,I'm a new learner to programming in Linux so kindly can you help me to write this simple script for me and it is lists all text files "*.TXT" in a directory and writes the first line of each text-file to a file called "Aby_Name".

    Thank you so much.

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    Code:
    for f in *.TXT; do awk 'NR==1{print $0}' $f >> Aby_name; done

  3. #3
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    you can also use the head command to do that:
    Code:
    head -1q *.TXT > Aby_Name

  4. #4
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6
    Thank you so mush

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...