- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Variable assignment
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 05:18 PM
тАО02-06-2007 05:18 PM
Variable assignment
for eg: if i have a variable named FILE and i want it to hold 2 filetypes so that in my further comparisons, FILE can take either of the 2 values.
Can anybody suggest???
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 05:23 PM
тАО02-06-2007 05:23 PM
Re: Variable assignment
Of course you can always assign a string to a variable with a delimiter between them.
>i want it to hold 2 filetypes so that in my further comparisons, FILE can take either of the 2 values.
I'm not sure what you want here. Is there something in C that does what you want? You don't want enums do you?
- Tags:
- ARRAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 05:37 PM
тАО02-06-2007 05:37 PM
Re: Variable assignment
will brief u on this.
i want FILE to hold 2 filetypes.
So that say.. if i want to put all the files with these filetypes somewhere else, i can directly use the variable FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 05:40 PM
тАО02-06-2007 05:40 PM
Re: Variable assignment
Can anybody give me the syntax for multiple if`s inside awk??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 06:07 PM
тАО02-06-2007 06:07 PM
Re: Variable assignment
So that say.. if i want to put all the files with these filetypes somewhere else, i can directly use the variable FILE
Well, you can concatenate all of the files in one variable (blank separators) and then use $FILE in commands like mv, etc.
FILE=$(ls *.c)
This will have the long string: a.c ... zzz.c
>Can anybody give me the syntax for multiple if's inside awk??
Same as C:
if (abc == def) {
...
} else {
...
}
You can add if-blocks after, or inside other ifs.
See awk(1).
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 06:48 PM
тАО02-06-2007 06:48 PM
Re: Variable assignment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2007 08:26 PM
тАО02-06-2007 08:26 PM
Re: Variable assignment
a general handling of your request can be done by arrays.
In the following awk example we check, if the second field matches one of the values in 'str' AND when the line contains 'here-we-are'. Having this verified, we process this line later:
awk -v str='one two three' 'BEGIN {n=split(str,ary); found=0}
/here-we-are/ { for(i=1;i<=n;i++) if($2~ary[i]) {found=1;break} }
found { print "processing",$0 }'
mfG Peter