Sponsored Content
Top Forums UNIX for Advanced & Expert Users Place the results of a CUT command into a variable Post 302891745 by talonbow on Friday 7th of March 2014 04:36:07 PM
Old 03-07-2014
Place the results of a CUT command into a variable

I am being passed a file in UNIX, ie: variable.txt

I need to extract the first part of the file content, up to the period, content ie: common_dir.second_output

Code:
cut -d'.' -f1 /content/stores/variable.txt



I then need to utilize the results to create a variable ($1), and test on that result. ie: $1 = common_dir

Code:
 if test -d /var/mqsi/deploy/$1
            then cd /var/mqsi/deploy && rm -Rf $1
             echo /var/mqsi/deploy/$1 deleted.
 else
             echo /var/mqsi/deploy/$1 does not exist.
 fi



How do I pipe or place the results of the cut command into the variable $1, so $1 = common_dir

Or what is the best command to accomplish this?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Setting the Results of a Command to a Variable

Hi, Hi, I run the command: hostname to get the host back from the server: db201 Now, I need to take that result and set it to a variable. Can anyone help me with this?? I need to be able to use the same script on multiple servers so I do not want to hardcode the hostname result into... (1 Reply)
Discussion started by: stky13
1 Replies

2. UNIX for Dummies Questions & Answers

Cut Command value assign to variable

Hi, I am new to UNIX Scripting. I have been trying to use the CUT command to retrieve part of the header from a file and assign it to a variable. I have tried searching a lot, but I am still unsuccessful. Sample Header: HJAN BALANCE 20090616 I need to retrieve the date here, which always... (10 Replies)
Discussion started by: ragz_82
10 Replies

3. Shell Programming and Scripting

Extract and place in variable

If i wanted to extract the number of collisions from the eth0 section of the ifconfig file and have the output placed in a variable how would i do this? I can get the output displayed using: /sbin/ifconfig eth0 | grep "collisions" What command would i now use to place the output in a... (1 Reply)
Discussion started by: warlock129
1 Replies

4. Shell Programming and Scripting

Place 'find' results within TeX command

Hi, In an effort to collect all my .java-files and place them in a LaTeXfile (using the listings environment of latex), i tried to use ex. So what i have now is: find . -name "*\.java" > latex ex latex <<HERE %s/\(.*\)/\\lstinputlisting{\1} wq HERE So i try to escape the '\' with... (1 Reply)
Discussion started by: HannesBBR
1 Replies

5. Shell Programming and Scripting

Cut text file in place

I have a file that i want to take only the first part of it and discard the rest, to be accurate,I need the first 137097 lines but I cant use split because I dont have enough space on my disck. I need sth to cut the file in its place (3 Replies)
Discussion started by: Heidi Heweidy
3 Replies

6. Shell Programming and Scripting

sed and cut command in variable

hi, i want to remove 12 and 13 column from psv files and dump them in new folder ls -ltr *GTDA_Dly_Pmix_*.psv>filename.xls var1=`cat filename.xls` for i in $var1 do var3=`echo "$i" |cut -d '|' -f12,13 |sort -u` sed -e 's/"|$var3"//g... (2 Replies)
Discussion started by: renuk
2 Replies

7. Shell Programming and Scripting

Storing command output in a variable and using cut/awk

Hi, My aim is to get the md5 hash of a file and store it in a variable. var1="md5sum file1" $var1 The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1 i just need to get the first part and put it into a variable. var1="md5sum file1"... (5 Replies)
Discussion started by: JustALol
5 Replies

8. UNIX for Beginners Questions & Answers

Results of ldapsearch piped to grep are cut off

ldapsearch -x -LLL -E pr=200/noprompt -h abc-loc.somecompany.com -D "account@somecompany.com" -w password -b "cn=groupname,ou=Resource,ou=groups,dc=abc,dc=somecompany,dc=com" | grep member Results are: member: CN=Hanson\, Joe,OU=End Users,OU=Accounts,DC=abc,DC=somecompany,DC=com member:... (3 Replies)
Discussion started by: who10
3 Replies

9. Shell Programming and Scripting

Use cut output as variable piped awk command

Hi, I would like use the output of my cut command as a variable in my following awk command. Here's what I've written. cut -f1 info.txt | awk -v i=xargs -F'' '{if($6 == $i) print $20}' summary.txt Where obviously the 'xargs' doesn't do what I want. How can I pass my cut result to my awk... (3 Replies)
Discussion started by: heyooo
3 Replies

10. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies
Mason::Filters::Standard(3pm)				User Contributed Perl Documentation			     Mason::Filters::Standard(3pm)

NAME
Mason::Filters::Standard - Standard filters DESCRIPTION
These filters are automatically composed into Mason::Component. FILTERS
Capture ($ref) Uses "$m->capture" to capture the content in $ref instead of outputting it. % $.Capture(my $content) {{ <!-- this will end up in $content --> % }} ... do something with $content CompCall ($path, @args...) Calls the component with path and @args, just as with "$m->scomp", with an additional coderef argument "yield" that can be invoked to generate the content. Arguments passed to "yield" can be accessed inside the content via @_. This is the replacement for Mason 1's Components With Content <http://search.cpan.org/perldoc?HTML::Mason::Devel#Component_Calls_with_Content>. In index.mc: % $.CompCall ('list_items.mi', items => @items) {{ <li><% $_[0] %></li> % }} In list_items.mi: <%class> has 'items'; has 'yield'; </%class> % foreach my $item (@{$.items}) { <% $.yield->($item) %> % } NoBlankLines Remove lines with only whitespace from content. This % $.NoBlankLines {{ hello world % }} yields hello world Repeat ($count) Repeat the content block $count times. Note that the block is re-executed each time, which may result in different content. <!-- Prints 1 to 5 --> % my $i = 1; % $.Repeat(5) {{ <% $i++ %><br> % }} Tee ($ref) Uses "$m->capture" to capture the content in $ref, and also output it. % $.Tee(my $content) {{ <!-- this will end up in $content and also be output --> % }} ... <!-- output content again down here --> <% $content %> Trim Remove whitespace from the beginning and end of the content. SEE ALSO
Mason::Manual::Filters, Mason AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jonathan Swartz. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-05-02 Mason::Filters::Standard(3pm)
All times are GMT -4. The time now is 06:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy