|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Passing an argument to cut command
Can we pass an argument to cut command as below
Suppose cut command is used in for or while loop and we need to pass the incremental counter cut -f$i Here $i is an argument. Like wise it has to come cut -f1 cut -f2 Where i=1,2,3,.... |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
As a general rule when wondering if a given construct works, try it and see what happens , (NB: does not apply to potentially destructive commands)Code:
for i in $(seq 10) ; do echo cut -d\, -f$i tmp.csv ; done cut -d, -f1 tmp.csv cut -d, -f2 tmp.csv cut -d, -f3 tmp.csv cut -d, -f4 tmp.csv cut -d, -f5 tmp.csv cut -d, -f6 tmp.csv cut -d, -f7 tmp.csv cut -d, -f8 tmp.csv cut -d, -f9 tmp.csv cut -d, -f10 tmp.csv Looks good to me... |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing argument on find command | ajithbe | Shell Programming and Scripting | 3 | 11-28-2011 09:13 AM |
| Passing argument to command in C | effizy | Programming | 3 | 09-26-2011 11:17 AM |
| Need Help with the argument passing Through Command line | asirohi | Shell Programming and Scripting | 5 | 09-04-2009 02:37 AM |
| passing argument from Cshelll to awk command | ganiel24 | Shell Programming and Scripting | 1 | 06-24-2009 10:57 AM |
| passing a command line argument | rudoraj | Shell Programming and Scripting | 8 | 06-13-2007 11:06 PM |
|
|