Sponsored Content
Full Discussion: Cut not working in a loop
Top Forums UNIX for Dummies Questions & Answers Cut not working in a loop Post 302368281 by KME on Wednesday 4th of November 2009 01:30:05 PM
Old 11-04-2009
Methyl,
Thank you so much for helping. I'm still having problems but the additional quotes were very insiteful, wierd but insiteful. I was able to cut in teh loop but I was never able to send the line to the function. That is ok however because i was able to get each field from the string as if it was awk $1,$2,etc..

However, my call to the FindPath3 function is now broken and i have no idea why. It gets called but the ${1} is blank/ i've tried several different formats with the quotes with the parameter and echo statement but no luck. Any more ideas. I realize there are possibly other ways to accomplish my task, but my objective is to learn how to pass these parameters in the functions as well as achieve the end result. I'll need this ability for other code.

Code:
 
    #!/usr/bin/ksh
 
function FindPath3 {
echo "here: ${1}"
 find /u03/hsun -name ${1} 
}
function MyPrint {   
tfile=`echo "${2}"`
 echo "tfile in myprint: ${2}"
 tPath= `FindPath3 test1a2.sas7bdat`
print $1,$2,$3,$4,$tPath > /home/kemard/Test3_OP.txt
} 
 while read line0
     do 
     #echo "$line0"
     MyPrint $line0
   done < /u03/kemard/BaseData.txt

BTW, in order to get the cut to work i had to use the quotes and feed the cut with a pipe rather than pass it from the right side:
Code:
 ## lineValue3=`echo "${line0}" | cut -f2 -d ' ' `

 

10 More Discussions You Might Find Interesting

1. Solaris

/usr/bin/cut not working with largefiles on Solaris 10

I have a person running a perl script that is parsing > 2G log files and pipes to cut -d " " -f 1,6,7,8... The script itself is in a nfs mounted home directory. It runs fine when started from a solaris 8 box but fails after about 400 lines when started from the solaris 10 box. The solaris... (1 Reply)
Discussion started by: wottie
1 Replies

2. Shell Programming and Scripting

Use loop var i within Cut Command

Hi, In the following bash code rather than cutting at a predefined character I would like to cut at position i (i var from loop). Is this possible? I have tried eval, but either it's not possible or my syntax is wrong. thanks Nick for i in {1..9} do theChar=$(echo... (3 Replies)
Discussion started by: de_la_espada
3 Replies

3. Shell Programming and Scripting

cut the present working directory

how to traverse through each directory (1 Reply)
Discussion started by: Reddy482
1 Replies

4. Shell Programming and Scripting

why the set rr='echo string|cut not working

I am new to the c shell script, can you let me know why the set rr= is not working. C shell script #! /bin/csh Set tt= 12345_UMR_BH452_3_2.txt set rr='echo $tt | cut –d”_” -f1' syntax error (4 Replies)
Discussion started by: jdsignature88
4 Replies

5. Shell Programming and Scripting

Problem in getting data from a loop using grep and cut

The script is following : for each_rec in <file_name> do count=`cut -c -2 ${each_rec} | grep "45"` echo ${count} if ] then amount=`cut -c 24-35 ${each_rec}` echo ${amount} else echo "failed" fi done And the file looks like below : ... (4 Replies)
Discussion started by: mady135
4 Replies

6. Shell Programming and Scripting

Using a loop with cut

I don't know if I described this right, but I am new to scripting and this is giving me a little bit of trouble, but I will explain what I am trying to do. Each time this is run, I want it to grab and save ls -l /home to data.txt. ls -l /home > data.txt Now the part I am getting confused... (4 Replies)
Discussion started by: ninjafish
4 Replies

7. UNIX for Dummies Questions & Answers

cut not working the way i want it to

Hi Forum Im having problem with cut it even when i cut a field from an input file eg echo $x | cut -f1 -d':' it doesnt read the whole line if there is a space in it eg thisLineHasA SpaceInIt :wall: it only read up to the space.What i want is so the it cut the field as one line ... (8 Replies)
Discussion started by: ShinTec
8 Replies

8. Shell Programming and Scripting

Cut command not working in for loop

grep -Fxvf testdata.xls file_GTDA1.xls >file_GTDA.xls SLS_COUNT=`grep 'GTDA_Dly_Sls' file_GTDA.xls |wc -l` PMIX_COUNT=`grep 'GTDA_Dly_Pmix' file_GTDA.xls |wc -l` if ; then var1=`cat file_GTDA.xls|grep 'GTDA_Dly_Sls_'` var4="|" for i in $var1... (7 Replies)
Discussion started by: renuk
7 Replies

9. Shell Programming and Scripting

CUT command not giving correct result inside loop

Hi, i have a source file and have 3 columns and separated by "|" .i want to split this 3 columns in different variable.When i am executing this values indivisually giving correct result but when the same execute inside a for loop,it's giving issues. Src file(jjj.txt) -------... (8 Replies)
Discussion started by: raju2016
8 Replies

10. Shell Programming and Scripting

Why is my cut command not working ?

OS : RHEL 6.8 Shell : bash I want to remove all lines like below from the history output as it has password. $ history | grep sqlplus 239 sqlplus jn_usr/dxc825#@10.5.12.106/OCSGPD 256 sqlplus osb_soa/KD1egM09@10.5.12.196/BSOAPRD 279 sqlplus jn_usr/dxc825#@10.80.16.219/OCSGPD... (5 Replies)
Discussion started by: John K
5 Replies
WMANAGER-LOOP(1)					    BSD General Commands Manual 					  WMANAGER-LOOP(1)

NAME
wmanager-loop -- loop running window managers chosen with wmanager SYNOPSIS
wmanager-loop [OPTIONS ...] DESCRIPTION
The wmanager-loop program starts either the window manager specified by the WM variable or the first window manager listed in ~/.wmanagerrc (or an X terminal emulator if none), and when it exits, runs wmanager(1) to prompt the user for the next window manager. It loops doing this until the user chooses ``Exit this session'' in wmanager(1). Any options given to wmanager-loop will be passed on to wmanager(1). If the WM environment variable is set, the wmanager-loop program tries to interpret it as a window manager specification in the following ways in the specified order: o a full path to an executable file to run as the window manager; o the name of a window manager listed in the /.wmanagerrc file; e.g. ``fluxbox'' would match the following line: fluxbox=/usr/bin/startfluxbox o the program name of a window manager listed in the /.wmanagerrc file; e.g. ``startfluxbox'' would match the above example. o the start of such a program name; e.g. ``start'' would match the above example. o the end of such a program name; e.g. ``box'' would match the above example. If the WM variable is set and there is more than one line in ~/.wmanagerrc that matches the specification, wmanager-loop will exit with an error message. As mentioned above, if no window manager is specified in the WM environment variable or found in the ~/.wmanagerrc file, the wmanager-loop program attempts to start an X terminal emulator. If the WMTERM environment variable is set, the wmanager-loop program uses it as the path to the emulator. Otherwise it searches the user's path for a program named ``x-terminal-emulator'', ``urxvt'', ``rxvt'', or ``xterm'' in this order, and starts the first one found using its full path. If none of the common terminal emulators on the above list is found, the wmanager-loop program just runs ``xterm'' in the hope that something will come up on the user's display. ENVIRONMENT
The wmanager-loop program uses the following environment variables: WM The name, path, or partial path to the first window manager to execute. WMTERM The name of the X terminal emulator to execute if no window manager could be found in the ~/.wmanagerrc file. If not specified, the wmanager-loop program searches the user's path as described above. EXAMPLE
To start using wmanager-loop, create a ~/.wmanagerrc file - generally with wmanagerrc-update(1) - and add something like the following at the end of your ~/.xsession file: exec wmanager-loop -geometry +570+585 SEE ALSO
wmanager(1), wmanagerrc-update(1) HISTORY
The wmanager-loop program was written by Tommi Virtanen in 2000 and later modified by Peter Pentchev. This manual page was originally writ- ten in perldoc format by Tommi Virtanen in 2000, and converted to mdoc format and updated by Peter Pentchev in 2008. AUTHORS
Tommi Virtanen <tv@debian.org> Peter Pentchev <roam@ringlet.net> BSD
September 8, 2009 BSD
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy