How to Toggle Flag/Switch Value with Sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Toggle Flag/Switch Value with Sed
Prev   Next
# 1  
Old 02-02-2011
How to Toggle Flag/Switch Value with Sed (Solved)

I am trying to figure out a one liner to toggle a flag variable. eg.
Code:
FLAG=0

Is there a way to use sed to toggle above example between 0 and 1. That is if run with flag set to zero it would change it to one if run again it would set it to zero.

I thought I had it figured but the expressions would end up switching it 2x.

Thank you,
Brian

Last edited by bsquared; 02-04-2011 at 11:22 AM.. Reason: Indicate solution found
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed print flag

I have an input file that looks something like this: .... key1: ABC .... key2: DEF .... key1: GGG .... key2: HHH .... The row of dots represents any number of lines that don't contain the strings "key1:" or "key2:" The strings key1: and key2: will always appear alternately as in the... (8 Replies)
Discussion started by: pmennen
8 Replies

2. UNIX for Dummies Questions & Answers

[Solved]Can anyone tell me why -H flag with sudo doesn't switch to the target user's home directory?

I have checked the man page ,which says : The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo does not modify HOME But I have tried below command: #... (1 Reply)
Discussion started by: Michaelw321
1 Replies

3. UNIX for Dummies Questions & Answers

sed "-n" switch

Hi Guys, i'm exploring sed and failed to understand the following. Can anyone with more knowledge of this explain this better. I have to read lines 4 to 6 in a file so i used the following command : sed '4,6 p' file but the above prints all lines instead! . when i use the -n... (3 Replies)
Discussion started by: Irishboy24
3 Replies

4. Shell Programming and Scripting

what is the switch to let sed edit and save file

I remember there is a sed switch i can use to edit and save the file at the same time, but i cannot recall it at all. so instead of -> sed 's/A/B/' file > file-tmp -> mv file-tmp file what can i do to just let sed edit and save the "file" (4 Replies)
Discussion started by: fedora
4 Replies

5. Programming

toggle bit

how can I toggle all the bits of any given number using a shortest C code (5 Replies)
Discussion started by: rupeshkp728
5 Replies

6. Shell Programming and Scripting

pass variable to sed like in awk (-v switch)

hi all is possible to pass shell (bash) variable to sed like it is in awk? example: awk script is storred in awk.awk file and I am passing variable called var to this file. $ cat awk.awk {if ($5==var) print $0} so it works when i issue $ bash_var=24 $ ls -l | awk -v... (1 Reply)
Discussion started by: wakatana
1 Replies

7. Shell Programming and Scripting

Perl script to toggle through dates by week

Hi, I need help to toggle through dates on a weekly basis to be fed into a script as inputs. The format should be: yyyy/mm/dd (start) yyyy/mm/dd (end), where end date is 7 days increments. The date (start) would be input as an ARGV and would continue until current date. I can check... (2 Replies)
Discussion started by: subhap
2 Replies

8. Shell Programming and Scripting

Toggle Hidden Files Mac OS X

Hi all, I have been using Ubuntu for 2 years now, and a few days ago I bought a Macbook. This is my first time using a Mac, so I have spent the better of two days learning the user interface, and configuring my Macbook. One thing I noticed is that there is no easy way to turn on and off hidden... (0 Replies)
Discussion started by: Omniwheel
0 Replies

9. Programming

How to toggle BACKSPACE/DEL function for backArrow key for terminal other than xterm?

Hi all, I've got the problem which I can't resolve with my knowledge :) For xterm terminal we have resource class XTerm*backarrowKey. If we set it to true, backspace code (ASCII 0x8) will be sent to program. We can get it using e.g. getc() function. If it is disabled getc() returns DEL(0x7F). ... (0 Replies)
Discussion started by: dmitryb
0 Replies
Login or Register to Ask a Question
ZHCON(1)							    User Manual 							  ZHCON(1)

NAME
zhcon - fast CJK console environment for GNU/Linux and BSD SYNOPSIS
zhcon [OPTIONS]... [FILES]... DESCRIPTION
Zhcon is a fast Linux console system which supports framebuffer device. It can display Chinese, Japanese and Korean double byte characters. Supported encodings are: GB2312, GBK, BIG5, JIS and KSC. It can also use input methods (table based) from MS pwin98 and UCDOS for MS-DOS. -h, --help Print help and exit -V, --version Print version and exit --utf8 use iconv filter to convert UTF-8 stream from/to system encoding (default=off) --drv=STRING specify video driver (auto, fb, ggi, vga) (default=`auto') If a program name is given as a command line argument, zhcon will run this program on start instead of a shell, and quit when the program exits. For example: zhcon screen will run screen in zhcon insteal of default user shell. CONFIGURATION FILE
On startup, zhcon first try to load configuration from ~/.zhconrc. If failed, it will use /etc/zhcon.conf by default. The configure file has many options that can be used to control the behavior of zhcon. See the comments in the file for instruction on customizing zhcon. KEY SUMMAY
CTRL_ALT_H: active online help ALT_SPACE: open/close CJK mode CTRL_SPACE: open/close input method ALT_SPACE: show/hide input bar CTRL_,: toggle Full/Half char mode CTRL_.: toggle Chinese symbol CTRL_F1: set encode to GB2312 CTRL_F2: set encode to GBK CTRL_F3: set encode to BIG5 CTRL_F4: set encode to JIS CTRL_F5: set encode to KSCM CTRL_F7: toggle between nativebar and overspot input style CTRL_F9: toggle GB2312/BIG5 auto-detect mode CTRL_F10: menu mode CTRL_ALT_1 - CTRL_ALT_9: switch to input method 1 to 9 CTRL_ALT_0: English mode History mode keys: SHIFT_PAGEUP: scroll up half screen in history SHIFT_PAGEDOWN: scroll down half screen in history SHIFT_ARROWUP: scroll up one line in history SHIFT_ARROWDOWN: scroll down one in history SEE ALSO
/usr/share/doc/zhcon/README.gz, /usr/share/doc/zhcon/manual.ps.gz. AUTHORS
ejoy <ejoy@users.sourceforge.net> Hu Yong <ccpaging@etang.com> Rick Lei <rick@chinaren.com> This manual page was written by Aron Xu <happyaron.xu@gmail.com>, for the Debian project (and may be used by others). Fast CJK console environment June 2011 ZHCON(1)