Sponsored Content
Full Discussion: Need to strip a string
Top Forums Shell Programming and Scripting Need to strip a string Post 302104741 by radoulov on Saturday 27th of January 2007 08:21:03 AM
Old 01-27-2007
Quote:
Originally Posted by x96riley3
I have a file that looks like this:

/home/fred/opt/bin
/opt/usr/bin
/usr/sbin/var/opt


I need a way to chop of everything after the last occurance of the / sign including the /. So the file above will now look like this below.


/home/fred/opt
/opt/usr
/usr/sbin/var
[...]
With bash:

Code:
set "$(<infile)"; printf "%s\n" "${@%/*}"

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to strip strins

Guys, Please can someone tell me how to strip each string from the following ? TABLE1||METHOD||TYPE||STATUS||DATE What i need is to assign each value to the variable TABLE1 to var1 METHOD to var2 and so on If there is NULL in one of them, something like A||B||||C|| I want the... (14 Replies)
Discussion started by: kamathg
14 Replies

2. Shell Programming and Scripting

Strip all non-alphanumerics

Hi, Can someone let me know how do I strip out any non-alphanumeric character in string tomake it alphanumeric? i.e abc def ghi ->abcdefghi abc-def-ghi ->abcdefghi abc#def-ghi->abcdefghi Thanks in advance (3 Replies)
Discussion started by: braindrain
3 Replies

3. Programming

Strip command

I am new in Unix. I go through the man strip. But did not understand that, why when we have -G (debug and release ) option in the compiler, than using strip command to strip the debug information from the objects. i want to binary for teh production i will compile it without debug option. What the... (4 Replies)
Discussion started by: Saurabh78
4 Replies

4. Shell Programming and Scripting

How to strip out common terms in string

Hi, I have this kinda of data:- 0,0,0,0,1,2,0,4,5,6,7,foo 0,0,0,0,1,4,0,5,5,5,5,foo1 0,0,6,0,1,6,0,6,1,2,3,orange etc... I wanted to remove the 0 which occur on the same rows of foo,foo1 and orange in this case. Desired output is:- 0,1,2,4,5,6,7,foo 0,1,4,5,5,5,5,foo1... (9 Replies)
Discussion started by: ahjiefreak
9 Replies

5. Shell Programming and Scripting

Strip a string in sh

I have a list of servers that I need my script to ping however this list also has the env they belong too such as SIT, PRD, warehouse and so on. The break character for each section is : A value in my list would look like this... brutus.grhq.xxx.com:warehouse Where brutus.grhq.gfs.com is... (13 Replies)
Discussion started by: LRoberts
13 Replies

6. Shell Programming and Scripting

Strip out the string

awk -F"\t" -vOFS="\t" '{print $1"\t-\t-","",$6,$7"\t-"$8"\t-\t-\t"$15}' file.tsv > output.tsv Using the above command how to remove the string www.abc.com from the $7 value. (7 Replies)
Discussion started by: sandy1028
7 Replies

7. Solaris

strip error

Hi I am getting the below error while using strip command. strip: libelf error. Request error: no string table strip: a.out: file not manipulated Could somebody please let me know what might be the solution?? It is in ksh and solaris 10. Thanks in advance (4 Replies)
Discussion started by: vali__
4 Replies

8. Shell Programming and Scripting

Strip First few Characters

I want to strip first few characters from each record until a proper datesamp is found. Request for getNextPage.................06/29/12 07:49:30 VVUKOVIC@67.208.166.131{7A805FEF76A62FCBB23EA78B5380EF95.tomcat1}TP-Processor14 LogExchUsage: ERROR:: isprof=false : exch=NSDQ output should be... (2 Replies)
Discussion started by: ratheeshjulk
2 Replies

9. Shell Programming and Scripting

Strip leading and numbers from a string.

Hello I have two vars loaded with $VAR1="ISOMETHING103" $VAR2="COTHERTHING04" I need to: 1) Strip the first char. Could be sed 's/^.//' 2) The number has it's rules. If it has "hundreds", it needs to be striped. If it is just two digits it shouldn't. So, for VAR1 output should be... (7 Replies)
Discussion started by: tristezo2k
7 Replies
lpr_selinux(8)							SELinux Policy lpr						    lpr_selinux(8)

NAME
lpr_selinux - Security Enhanced Linux Policy for the lpr processes DESCRIPTION
Security-Enhanced Linux secures the lpr processes via flexible mandatory access control. The lpr processes execute with the lpr_t SELinux type. You can check if you have these processes running by executing the ps command with the -Z qualifier. For example: ps -eZ | grep lpr_t ENTRYPOINTS
The lpr_t SELinux type can be entered via the lpr_exec_t file type. The default entrypoint paths for the lpr_t domain are the following: /usr/bin/lp(.cups)?, /usr/bin/lpq(.cups)?, /usr/bin/lpr(.cups)?, /usr/bin/lprm(.cups)?, /usr/sbin/lpc(.cups)?, /usr/bin/cancel(.cups)?, /usr/bin/lpstat(.cups)?, /opt/gutenprint/bin(/.*)?, /opt/gutenprint/sbin(/.*)?, /usr/linuxprinter/bin/l?lpr, /usr/local/linux- printer/bin/l?lpr, /usr/sbin/accept, /usr/sbin/lpinfo, /usr/sbin/lpmove, /usr/sbin/lpadmin, /usr/bin/lpoptions PROCESS TYPES
SELinux defines process types (domains) for each process running on the system You can see the context of a process using the -Z option to ps Policy governs the access confined processes have to files. SELinux lpr policy is very flexible allowing users to setup their lpr pro- cesses in as secure a method as possible. The following process types are defined for lpr: lpr_t Note: semanage permissive -a lpr_t can be used to make the process type lpr_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated. BOOLEANS
SELinux policy is customizable based on least access required. lpr policy is extremely flexible and has several booleans that allow you to manipulate the policy and run lpr with the tightest access possible. If you want to allow users to resolve user passwd entries directly from ldap rather then using a sssd server, you must turn on the authlo- gin_nsswitch_use_ldap boolean. Disabled by default. setsebool -P authlogin_nsswitch_use_ldap 1 If you want to deny any process from ptracing or debugging any other processes, you must turn on the deny_ptrace boolean. Enabled by default. setsebool -P deny_ptrace 1 If you want to allow all domains to use other domains file descriptors, you must turn on the domain_fd_use boolean. Enabled by default. setsebool -P domain_fd_use 1 If you want to allow all domains to have the kernel load modules, you must turn on the domain_kernel_load_modules boolean. Disabled by default. setsebool -P domain_kernel_load_modules 1 If you want to allow all domains to execute in fips_mode, you must turn on the fips_mode boolean. Enabled by default. setsebool -P fips_mode 1 If you want to enable reading of urandom for all domains, you must turn on the global_ssp boolean. Disabled by default. setsebool -P global_ssp 1 If you want to allow confined applications to run with kerberos, you must turn on the kerberos_enabled boolean. Enabled by default. setsebool -P kerberos_enabled 1 If you want to allow system to run with NIS, you must turn on the nis_enabled boolean. Disabled by default. setsebool -P nis_enabled 1 If you want to allow confined applications to use nscd shared memory, you must turn on the nscd_use_shm boolean. Disabled by default. setsebool -P nscd_use_shm 1 If you want to support ecryptfs home directories, you must turn on the use_ecryptfs_home_dirs boolean. Disabled by default. setsebool -P use_ecryptfs_home_dirs 1 If you want to support fusefs home directories, you must turn on the use_fusefs_home_dirs boolean. Disabled by default. setsebool -P use_fusefs_home_dirs 1 If you want to determine whether to support lpd server, you must turn on the use_lpd_server boolean. Disabled by default. setsebool -P use_lpd_server 1 If you want to support NFS home directories, you must turn on the use_nfs_home_dirs boolean. Disabled by default. setsebool -P use_nfs_home_dirs 1 If you want to support SAMBA home directories, you must turn on the use_samba_home_dirs boolean. Disabled by default. setsebool -P use_samba_home_dirs 1 NSSWITCH DOMAIN
If you want to allow users to resolve user passwd entries directly from ldap rather then using a sssd server for the lpr_t, you must turn on the authlogin_nsswitch_use_ldap boolean. setsebool -P authlogin_nsswitch_use_ldap 1 If you want to allow confined applications to run with kerberos for the lpr_t, you must turn on the kerberos_enabled boolean. setsebool -P kerberos_enabled 1 MANAGED FILES
The SELinux process type lpr_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Note the processes UID still need to have DAC permissions. lpr_tmp_t print_spool_t /var/spool/lpd(/.*)? /var/spool/cups(/.*)? /var/spool/cups-pdf(/.*)? FILE CONTEXTS
SELinux requires files to have an extended attribute to define the file type. You can see the context of a file using the -Z option to ls Policy governs the access confined processes have to these files. SELinux lpr policy is very flexible allowing users to setup their lpr processes in as secure a method as possible. STANDARD FILE CONTEXT SELinux defines the file context types for the lpr, if you wanted to store files with these types in a diffent paths, you need to execute the semanage command to sepecify alternate labeling and then use restorecon to put the labels on disk. semanage fcontext -a -t lpr_exec_t '/srv/lpr/content(/.*)?' restorecon -R -v /srv/mylpr_content Note: SELinux often uses regular expressions to specify labels that match multiple files. The following file types are defined for lpr: lpr_exec_t - Set files with the lpr_exec_t type, if you want to transition an executable to the lpr_t domain. Paths: /usr/bin/lp(.cups)?, /usr/bin/lpq(.cups)?, /usr/bin/lpr(.cups)?, /usr/bin/lprm(.cups)?, /usr/sbin/lpc(.cups)?, /usr/bin/can- cel(.cups)?, /usr/bin/lpstat(.cups)?, /opt/gutenprint/bin(/.*)?, /opt/gutenprint/sbin(/.*)?, /usr/linuxprinter/bin/l?lpr, /usr/local/linuxprinter/bin/l?lpr, /usr/sbin/accept, /usr/sbin/lpinfo, /usr/sbin/lpmove, /usr/sbin/lpadmin, /usr/bin/lpoptions lpr_tmp_t - Set files with the lpr_tmp_t type, if you want to store lpr temporary files in the /tmp directories. Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the semanage fcontext command. This will modify the SELinux labeling database. You will need to use restorecon to apply the labels. COMMANDS
semanage fcontext can also be used to manipulate default file context mappings. semanage permissive can also be used to manipulate whether or not a process type is permissive. semanage module can also be used to enable/disable/install/remove policy modules. semanage boolean can also be used to manipulate the booleans system-config-selinux is a GUI tool available to customize SELinux policy settings. AUTHOR
This manual page was auto-generated using sepolicy manpage . SEE ALSO
selinux(8), lpr(8), semanage(8), restorecon(8), chcon(1), sepolicy(8) , setsebool(8) lpr 14-06-10 lpr_selinux(8)
All times are GMT -4. The time now is 11:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy