LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2016, 04:07 PM   #1
PoleStar
Member
 
Registered: Jul 2010
Posts: 207

Rep: Reputation: 2
shell script. read line + split equivalent


Hi,

I need to read and manipulate command out put.

suppose
Quote:
>ls -l
temp = read_line ## out put of ls -l line by line
$temp[1] $temp[2]
I am not looking for cut/awk.
I have to actually see what comes in each line and decide things based on it.

Like you would do in perl

Quote:
Stemp = split($_ , ' ' ) ;
print "look at $temp[2]" ;
But in my case it would command out put.
Please help.
Thanks

Last edited by PoleStar; 01-29-2016 at 04:10 PM.
 
Old 01-29-2016, 08:06 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,593

Rep: Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069
C Programming


Code:
#include <stdio.h>
main ()
{
  FILE *fp;
  float total;
  fp = fopen("data.txt", "w+");
  if (fp == NULL) {
    printf("data.txt does not exist, please check!\n");
    exit (1);
  }
  fprintf(fp, 100);
  fscanf(fp, "f", &total);
  fclose(fp);
  printf("Value of total is f\n", total);
}

Last edited by BW-userx; 01-29-2016 at 08:09 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 07:07 PM
[SOLVED] [Shell script] How to read, filter and split from text file Mr.Tee Linux - Newbie 4 01-01-2016 04:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration