Read in txt file and run a different command for each line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read in txt file and run a different command for each line
# 1  
Old 05-25-2017
Read in txt file and run a different command for each line

hi,

i'm trying to write a tcsh script that reads in a text file (one column) and the runs a different command for each line of text.

i've found lots of example commands for bash, but not for tcsh.

can anyone give me a hint?

thanks,
jill
This User Gave Thanks to giuinha For This Post:
# 2  
Old 05-26-2017
tcsh hmmm stands for "turbo" C-SHELL ? ...
Was used a lot in the early years of SunOS, at the time FORTRAN, assembler and C was used intensively... as was mostly used by C language programmers as offered more than the basic Bourne shell only times have changed Korn has evolved a lot and with GNU stuff and linux arriving and widespread so did the usage of bash...
Why would one use tcsh currently unless he is a C aficionado?
All I can suggest then is to look back in older literature like manuals of SunOS4 or anything early 90' where it was commonly used - I remember of a good documentation maybe around 93 I used then with linux v.a99p118 ... Dont remember if it were part of that slackware release.
Good luck, what is wrong with bash or ksh? Is it you are using an old BSD?
# 3  
Old 05-26-2017
Quote:
Originally Posted by giuinha
hi,
i've found lots of example commands for bash, but not for tcsh.

can anyone give me a hint?

thanks,
jill
If I understand you right, you are looking for a tutorial which teaches you tcsh programming. There won't be much around, since the number of tcsh programmers is, as I have the impression, very small. Even RosetteCode (Category:Programming Languages - Rosetta Code ), which hosts many obscure languages, has no entry for tcsh! You can try

A basic tutorial on the tcsh shell

but in any case also read Csh Programming Considered Harmful . While this targets csh, many of the points discussed in this text also apply to tcsh.
# 4  
Old 05-26-2017
rather than a basic tutorial, i'm hoping someone can tell me how to gain this one functionality in my script.

why use tcsh? my guess is because the software package i'm running is basically a collection of C programs and most of the scripting from the developers uses tcsh. the developers ecommend using tcsh with their software. they program more and more in python now, but a lot of the programs in teh collection are in C.
# 5  
Old 05-26-2017
Quote:
Originally Posted by giuinha
why use tcsh? my guess is because the software package i'm running is basically a collection of C programs
non-sequitor. tcsh has no special features related to using C programs. "C-shell" is nothing but buzzwording, the same way javascript isn't java.
Quote:
and most of the scripting from the developers uses tcsh.
How old is this program?
# 6  
Old 05-26-2017
i only mentioned C because the previous poster mentioned that tcsh was used a lot by c programmers. i'm no expert in these matters.

as to when it was written, it started in the mid nineties, and development is ongoing.
# 7  
Old 05-26-2017
You could do a case statement in tcsh like this, but its not recommended.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Split Every Line In Txt Into Separate Txt File, Named Same As The Line

Hi All Is there a way to export every line into new txt file where by the title of each txt output are same as the line ? I have this txt files containing names: Kandra Vanhooser Rhona Menefee Reynaldo Hutt Houston Rafferty Charmaine Lord Albertine Poucher Juana Maes Mitch Lobel... (2 Replies)
Discussion started by: Nexeu
2 Replies

2. Shell Programming and Scripting

Read file and run a command

Hi I have jobs (some 1000) defined in a file and I want to read those jobs and run a a command. For example: jobs.txt abc efg I want to read the entire file and run the following command Delete -JOB "abc" Deleteing abc... Delete -JOB "efg" Delete efg... Can somebody help me... (4 Replies)
Discussion started by: karan8810
4 Replies

3. UNIX for Dummies Questions & Answers

Read workstation list from file und run command

Hi, how do I read in a file which includes a list of workstations and then run a command for each workstation ? I am unclear which command to use to read in , or is this not possible ? Thanks, (3 Replies)
Discussion started by: manni2
3 Replies

4. Shell Programming and Scripting

Repeat command with new variable for each line in txt file

Well here is my question. Let's say I have this Script: find /var/mobile/ maxdepth -2 name "$x" >> /"$x".txt The thing is I want to repeat this script and pull out a variable from a text file like this (each line = new variable $x and another run of the whole command) Thanks for... (27 Replies)
Discussion started by: pasc
27 Replies

5. Shell Programming and Scripting

Read 2 lines from File, Run Command based off output

Okay, so I have a file containing line after line of three digit numbers. I need a script that does an action based on the last two numbers in this list. So.... To get the last two numbers, I can have the script do tail -2 filename.txt But where I run into trouble is as follows. If... (6 Replies)
Discussion started by: UCCCC
6 Replies

6. Shell Programming and Scripting

read line and run a different command according to the output

Hi. I'm trying to write a script that reads a line on a file and runs a different command for a different line output. For example, if it finds the word "Kuku" on the line it sends mail to Kuku@kuku.com. Otherwise, it sends mail to Lulu@lulu.com. TIA. (2 Replies)
Discussion started by: Doojek9
2 Replies

7. UNIX for Dummies Questions & Answers

Command to delete numbers at beginning of txt file line

Hello. I have the following issue: my txt file has the following format: train/dr4/fklc0/sx175.txt 0 80282 Severe myopia contributed to Ron's inferiority complex. train/dr4/fklc0/sx355.txt 0 42906 Dolphins are intelligent marine mammals. train/dr4/fklc0/sa2.txt awk 'NR%2==0' test1.txt >... (4 Replies)
Discussion started by: li_bi
4 Replies

8. Shell Programming and Scripting

i need to read the last line in a txt file

i'm a beginner in shell and i have a txt file that is updating every second or msec so i need a program to read the last line of this txt file is this possible to do? (5 Replies)
Discussion started by: _-_shadow_-_
5 Replies

9. UNIX for Dummies Questions & Answers

How to read last line of a txt file?

I need to read the last file for a particular day, such as, "Jun 13" because the CSV file is cumulative for the entire day, so I don't want all the previous files, I just want the last file, for that day. I ran an 'ls -al | grep "June 13" > myLs.txt' (simplified) to list all files from that day.... (2 Replies)
Discussion started by: yongho
2 Replies

10. UNIX for Dummies Questions & Answers

want to read txt fileline by line

Hi , i want to read a text file line by line , is there any unix command or utility for this ? please tell me how to use it also ? (2 Replies)
Discussion started by: dharmesht
2 Replies
Login or Register to Ask a Question