02-22-2010
Removing a character from a variable and assigning it to another variable?
Hi folks.
I have this variable called FirstIN that contains something like this: 001,002,003,004...
I am trying to assign the content of this variable into ModifiedIN but with the following format : 001 002 003 004...(changing the commas for spaces)
I thought about using sed but i am not getting the expected result...which i guess is due to my misunderstanding of the command...
Maybe with tr instead? How would i copy the content of the original var into the second var while using tr? tried ModifiedIN=$FirstIN | tr ',' ' ' but that is wrong...
Thanks.
Last edited by Stephan; 02-22-2010 at 02:39 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Another newbie to Unix scripting Q..
How do you assign a value resulting from a command, such as awk, to a variable.
I am currently trying:-
$awk '{print $1}' file1 > variable1
with no change to $variable1.
The line:
$awk '{print $1}' file1
does print the first line of the... (3 Replies)
Discussion started by: sirtrancealot
3 Replies
2. Shell Programming and Scripting
Hi
In my shell script, I'm trying to find the line count of a file and assign it to a variable.
LINE_COUNT=$(wc -l $FILE_NAME)
But when i display LINE_COUNT, i'm getting the linecount concatenated with the file name. I want only the number. How can i get the line count alone ? Someone... (2 Replies)
Discussion started by: janemary.a
2 Replies
3. Shell Programming and Scripting
Hello there,
I have a variable in the form of '/example/file.txt' . I want to remove the ' characters from the beginning and the end so that the my new variable becomes /example/file.txt . How can I do it in a script?
I know this is a fairly easy question, but i wasn't able to implement it. (3 Replies)
Discussion started by: sertansenturk
3 Replies
4. Shell Programming and Scripting
hi all,
in ksh, how do i assign the output of a find command to a variable, e.g
am trying something like this :
totalNoFiles=$(print find ./ -name "SystemOut*.log");
but when i echo $totalNoFiles it displays
find ./ -name "SystemOut*.log"
instead of the total number of... (2 Replies)
Discussion started by: cesarNZ
2 Replies
5. UNIX for Advanced & Expert Users
echo "hello123" | tr -dc '' | wc -c
using this command i can count the no of times a number from 0-9 occurs in the string "hello123"
but how do i save this result inside a variable?
if i do
x= echo "hello123" | tr -dc '' | wc -c
that does not work...plz suggest..thanks (3 Replies)
Discussion started by: arindamlive
3 Replies
6. Shell Programming and Scripting
my script is some thing like this
i11="{1,2,3,4,5,6,7,8,9,10,11,}"
echo "enter value"
read value ..............suppose i11
x="$value"
echo "$($value)" .............the echo should be {1,2,3,4,5,6,7,8,9,10,11,}
but its showing "i11" only.
plz help me out to get desired... (10 Replies)
Discussion started by: sagar_1986
10 Replies
7. Shell Programming and Scripting
Hi
I have a script that accepts an input date in YYYY-MM-DD format.
After that, I used sed to delete the hyphen (-) which gives me an output YYYY MM DD.
My question is, how can I assign those three numbers to a three different variable.
Example:
2013-11-23 will become 2013 11 23... (4 Replies)
Discussion started by: erin00
4 Replies
8. Shell Programming and Scripting
Unable to get the value to a variable.
set -x
cd $HOME
echo "Enter the server name"
read a
echo $a
i=4
j=1
k = ps -ef | awk '/server1/{ print $4 }' | tail -$i | head -$j`
echo $k
When I do the same in command line it works, however the same does not work when I provide that in the... (1 Reply)
Discussion started by: venkidhadha
1 Replies
9. Shell Programming and Scripting
I have a date column as 06302015 but I need to have variable which extracts 063015.
Am trying something like below but it is not assigning
Please let me know if am missing something. Thanks in advance.
################################
#!/usr/bin/ksh
DT=06302015
... (7 Replies)
Discussion started by: weknowd
7 Replies
10. Shell Programming and Scripting
I have a data file d0 that looks like this:
$cat d0
server1 running -n-cv- 8G 3.1% 1435d 15h
server2 running -n---- 8G 39% 660d 22h
server3 running -n--v- 8G 2.5% 1173d 6h
server4 running -n---- 8G 1.1% 1048d 20h... (2 Replies)
Discussion started by: jake0391S
2 Replies
LEARN ABOUT DEBIAN
dahdi_hardware
DAHDI_HARDWARE(8) User Contributed Perl Documentation DAHDI_HARDWARE(8)
NAME
dahdi_hardware - Shows Dahdi hardware devices.
SYNOPSIS
dahdi_hardware [-v][-x]
OPTIONS
-v Verbose ouput - show spans used by each device etc. Currently only implemented for the Xorcom Astribank.
-x Show disconnected Astribank unit, if any.
DESCRIPTION
Show all dahdi hardware devices. Devices are recognized according to lists of PCI and USB IDs in Dahdi::Hardware::PCI.pm and
Dahdi::Hardware::USB.pm . For PCI it is possible to detect by sub-vendor and sub-product ID as well.
The first output column is the connector: a bus specific field that shows where this device is.
The second field shows which driver should handle the device. a "-" sign marks that the device is not yet handled by this driver. A "+"
sign means that the device is handled by the driver.
For the Xorcom Astribank (and in the future: for other Dahdi devices) some further information is provided from the driver. Those extra
lines always begin with spaces.
Example output:
Without drivers loaded:
usb:001/002 xpp_usb- e4e4:1152 Astribank-multi FPGA-firmware
usb:001/003 xpp_usb- e4e4:1152 Astribank-multi FPGA-firmware
pci:0000:01:0b.0 wctdm- e159:0001 Wildcard TDM400P REV H
With drivers loaded, without -v:
usb:001/002 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware
usb:001/003 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware
pci:0000:01:0b.0 wctdm+ e159:0001 Wildcard TDM400P REV E/F
With drivers loaded, with -v:
usb:001/002 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware
LABEL=[usb:123] CONNECTOR=usb-0000:00:1d.7-1
XBUS-00/XPD-00: FXS Span 2
XBUS-00/XPD-10: FXS Span 3
XBUS-00/XPD-20: FXS Span 4
XBUS-00/XPD-30: FXS Span 5
usb:001/003 xpp_usb+ e4e4:1152 Astribank-multi FPGA-firmware
LABEL=[usb:4567] CONNECTOR=usb-0000:00:1d.7-4
XBUS-01/XPD-00: FXS Span 6 XPP-SYNC
XBUS-01/XPD-10: FXO Span 7
XBUS-01/XPD-20: FXO Span 8
XBUS-01/XPD-30: FXO Span 9
pci:0000:01:0b.0 wctdm+ e159:0001 Wildcard TDM400P REV E/F
perl v5.14.2 2009-04-20 DAHDI_HARDWARE(8)